-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix pd.Timedelta(None) to return NaT. #13723
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
Conversation
Current coverage is 84.57% (diff: 100%)
|
@@ -667,3 +667,4 @@ Bug Fixes | |||
- Bug where ``pd.read_gbq()`` could throw ``ImportError: No module named discovery`` as a result of a naming conflict with another python package called apiclient (:issue:`13454`) | |||
- Bug in ``Index.union`` returns an incorrect result with a named empty index (:issue:`13432`) | |||
- Bugs in ``Index.difference`` and ``DataFrame.join`` raise in Python3 when using mixed-integer indexes (:issue:`13432`, :issue:`12814`) | |||
- Bug in ``pd.Timedelta(None)`` raises ``ValueError``. This is different from ``pd.Timestamp(None)`` and ``pd.Period(None)``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a reference to an issue number? (see how the other entries do it, you can use the PR number)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Period(None)
is also changed in this version (#13609), thus no need to refer here.
Actually, regarding no arguments, Timestamp raises in that case:
So not sure if we should let it here return NaT. |
no |
Rebased and updated. |
pls add a whatsnew note. FYI, PR's always need notes & tests & sometimes doc updates. These are often much more effort, than the actual code change. Esp for tests these need to be done upfront. |
Sorry I misunderstood what sinhrks said. I added a whatsnew note. |
Before this commit pd.Timedelta raised ValueError when None is passed. This behavior is inconsistent because * pd.Timestamp(None) and pd.Period(None) return NaT * pd.Timedelta returns NaT if '', 'nat', 'NAT' or np.nan is passed
@@ -755,3 +755,4 @@ Bug Fixes | |||
- Bug where ``pd.read_gbq()`` could throw ``ImportError: No module named discovery`` as a result of a naming conflict with another python package called apiclient (:issue:`13454`) | |||
- Bug in ``Index.union`` returns an incorrect result with a named empty index (:issue:`13432`) | |||
- Bugs in ``Index.difference`` and ``DataFrame.join`` raise in Python3 when using mixed-integer indexes (:issue:`13432`, :issue:`12814`) | |||
- Bug in ``pd.Timedelta(None)`` raises ``ValueError``. This is different from ``pd.Timestamp(None)`` (:issue:`13687`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is different from
pd.Timestamp(None)
what does that mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this commit aim to keep consistency with other Time related class.
So I added behavior of other class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
- Bug in
pd.Timedelta(None)
raisesValueError
rather than returningpd.NaT
as the same aspd.Timestamp(None)
pls wait for @jreback and @jorisvandenbossche comments as i'm not a native:)
thanks, whatsnew here |
😍 Thanks! |
git diff upstream/master | flake8 --diff
Before this commit pd.Timedelta raised ValueError
when None is passed.
This behavior is inconsistent because
is passed
This PR is related to #13687 (comment)