-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
DatetimeDatetime data dtypeDatetime data dtypeError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandas
Milestone
Description
It's not really an issue, just a suggestion. I noticed this behavior when initialising a timestamp:
# this doesn't fail
pd.Timestamp('2020')
# this does
pd.Timestamp(year=2020)
I guess that the latter fails because of args/kwargs specification issues (when an integer is passed it is read as a posix timestamp in the first place), and I'm OK with it. However, the error it raises is:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-e2faf77534f3> in <module>
----> 1 pd.Timestamp(year=2020)
pandas/_libs/tslibs/timestamps.pyx in pandas._libs.tslibs.timestamps.Timestamp.__new__()
TypeError: an integer is required (got type NoneType)
This is a bit misleading for beginners - it doesn't say anything about why it failed, but just about what failed.
Is there a chance it can be changed to something more explicit in the long term? Something like "provide at least year, month, day"?
Metadata
Metadata
Assignees
Labels
DatetimeDatetime data dtypeDatetime data dtypeError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandas