Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pd.NaT creates unexpected behavior in TimeSeries #230

Open
nsteins opened this issue May 4, 2020 · 0 comments
Open

pd.NaT creates unexpected behavior in TimeSeries #230

nsteins opened this issue May 4, 2020 · 0 comments

Comments

@nsteins
Copy link
Contributor

nsteins commented May 4, 2020

When using pandas Timestamps to create TimeSeries, any NaT values create unexpected results. For example the following snippet

import traces
import pandas as pd

ts = traces.TimeSeries({pd.Timestamp('2018-10-15 16:45:01'): 1,
                        pd.Timestamp('2019-02-22 12:05:08'): 2,
                        pd.NaT: 3,
                        pd.Timestamp('2019-04-16 13:08:26'): 4})

ts[pd.Timestamp('2019-02-21')]

returns 3

I suspect this is because pd.NaT implements comparisons in a different way than standard Python. e.g.

>>>pd.Timestamp('2019-01-01') >= pd.NaT
False
>>>pd.Timestamp('2019-01-01') <= pd.NaT
False
>>> pd.Timestamp('2019-01-01') > None
TypeError: '>' not supported between instances of 'Timestamp' and 'NoneType'

This difference is probably breaking the way the sortedcontainers implementation. Not sure what the best way to handle is, I could see either returning an error if a NaT is added to a TimeSeries or trying to convert the type to something else that is a bit more consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant