-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
DatetimeDatetime data dtypeDatetime data dtypeEnhancementError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action
Description
xref #15828
Currently, if ordinals are passed to to_datetime
without a unit, a ns
resolution is assumed. Given relative rarity of ns ordinals in the wild, I've been tripped up by this, e.g., below. I wonder if it would be better to raise in the case of no unit, and force ordinal parsing to always be explicit?
ordinals = pd.Series([1483228800000, 1483315200000, 1483401600000])
pd.to_datetime(ordinals) # wrong
Out[49]:
0 1970-01-01 00:24:43.228800
1 1970-01-01 00:24:43.315200
2 1970-01-01 00:24:43.401600
dtype: datetime64[ns]
pd.to_datetime(ordinals, unit='ms')
Out[51]:
0 2017-01-01
1 2017-01-02
2 2017-01-03
dtype: datetime64[ns]
jorisvandenbossche
Metadata
Metadata
Assignees
Labels
DatetimeDatetime data dtypeDatetime data dtypeEnhancementError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action