-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Return value of boolean datetime fields of NaT: False or NaN ? #15781
Labels
Milestone
Comments
4 tasks
PR on top of #15589 |
jreback
added a commit
to jreback/pandas
that referenced
this issue
Mar 22, 2017
Merged
jreback
added a commit
to jreback/pandas
that referenced
this issue
Mar 22, 2017
TST: add pandas/tests/scalar/test_nat TST: revise testing of tseries accessors closes pandas-dev#15781
jreback
added a commit
to jreback/pandas
that referenced
this issue
Mar 22, 2017
TST: add pandas/tests/scalar/test_nat TST: revise testing of tseries accessors closes pandas-dev#15781
jreback
added a commit
to jreback/pandas
that referenced
this issue
Mar 27, 2017
TST: add pandas/tests/scalar/test_nat TST: revise testing of tseries accessors closes pandas-dev#15781
jorisvandenbossche
pushed a commit
that referenced
this issue
Mar 27, 2017
TST: add pandas/tests/scalar/test_nat TST: revise testing of tseries accessors closes #15781
mattip
pushed a commit
to mattip/pandas
that referenced
this issue
Apr 3, 2017
TST: add pandas/tests/scalar/test_nat TST: revise testing of tseries accessors closes pandas-dev#15781
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From discussion in #15589, the handling of NaT is different for different datetime fields.
On a scalar value,
is_leap_year
returns False, the others are not defined:On an index (or series
.dt
accessor),is_leap_year
returns False, the others propagate NaN (with the consequence it is no longer a boolean array/series):So when
is_leap_year
was introduced in #13739, this was done on purpose, citing @sinhrks "pd.NaT.is_leap_year results in False, as I think users want bool array.".This seems indeed the more logical thing to return (certainly for arrays/series), so you can eg use it for indexing. For scalars it is a bit less clear what is the preferable option (return False or NaN), but probably best to be consistent.
The text was updated successfully, but these errors were encountered: