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

Series.__sub__(NaT) vs DatetimeIndex.__sub__(NaT) #18808

Closed
jbrockmendel opened this Issue Dec 16, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@jbrockmendel
Member

jbrockmendel commented Dec 16, 2017

One treats NaT result as datetime, other treats it as timedelta.

>>> dti  = pd.DatetimeIndex([pd.NaT, pd.Timestamp('19900315')])
>>> ser = pd.Series(dti)

>>> dti - pd.NaT
TimedeltaIndex([NaT, NaT], dtype='timedelta64[ns]', freq=None)

>>> ser - pd.NaT
0   NaT
1   NaT
dtype: datetime64[ns]
@gfyoung

This comment has been minimized.

Member

gfyoung commented Dec 17, 2017

Hmmm...that does seem a little inconsistent. Have a look as to why that's happening.

@jreback jreback added this to the Next Major Release milestone Dec 18, 2017

@jreback

This comment has been minimized.

Contributor

jreback commented Dec 18, 2017

I would argue that the series is wrong here. a sub operation with a DTI-like should always yield a TDI-like.

@jbrockmendel

This comment has been minimized.

Member

jbrockmendel commented Dec 18, 2017

I would argue that the series is wrong here. a sub operation with a DTI-like should always yield a TDI-like.

So I can change that and consider it a bugfix as opposed to a Breaking Change?

@jreback

This comment has been minimized.

Contributor

jreback commented Dec 18, 2017

no its a breaking change, but you can still change it

@jbrockmendel

This comment has been minimized.

Member

jbrockmendel commented Dec 19, 2017

Got a fix for this about ready. Two questions.

One: there are a couple of tests in series.test_operators test_datetime64_ops_nat that specifically check for the return type to be datetime64. Sure the behavior isn't intentional?

Two: also in test_datetime64_ops_nat are tests for -pd.NaT + Series[datetime64]. Should that also be changed to return Series[timedelta64]?

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