Skip to content

datetime operations on NaT produce dangerous results #8689

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

Closed
danfrankj opened this issue Oct 31, 2014 · 1 comment · Fixed by #8695
Closed

datetime operations on NaT produce dangerous results #8689

danfrankj opened this issue Oct 31, 2014 · 1 comment · Fixed by #8695
Labels
Bug Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@danfrankj
Copy link
Contributor

In [189]: ser = pd.Series([np.datetime64('nat')])

In [190]: ser
Out[190]: 
0   NaT
dtype: datetime64[ns]

In [191]: ser.dt.hour
Out[191]: 
0   -1
dtype: int64

While -1 is not a valid hour it is a very valid integer and could (has) caused hard to track bugs.

@jreback
Copy link
Contributor

jreback commented Oct 31, 2014

hmm this is not tested ATM
(as indexes only recently started allowing NaT ; that is how .dt is implemented )

marking as a bug

if u would like to take a shot at fixing lmk

@jreback jreback added Bug Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Oct 31, 2014
@jreback jreback added this to the 0.15.1 milestone Oct 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants