Skip to content

nat division by timedelta #17955

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

Merged
merged 6 commits into from
Oct 28, 2017
Merged

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Oct 23, 2017

xref #17876

Does the whatsnew note still go in 0.20.0.txt?

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@jbrockmendel jbrockmendel mentioned this pull request Oct 23, 2017
@codecov
Copy link

codecov bot commented Oct 23, 2017

Codecov Report

Merging #17955 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17955      +/-   ##
==========================================
- Coverage   91.23%   91.22%   -0.02%     
==========================================
  Files         163      163              
  Lines       50113    50113              
==========================================
- Hits        45723    45714       -9     
- Misses       4390     4399       +9
Flag Coverage Δ
#multiple 89.03% <ø> (ø) ⬆️
#single 40.31% <ø> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.75% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1dabf3...ac19de6. Read the comment docs.

@codecov
Copy link

codecov bot commented Oct 23, 2017

Codecov Report

Merging #17955 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17955      +/-   ##
==========================================
- Coverage   91.24%   91.23%   -0.02%     
==========================================
  Files         163      163              
  Lines       50168    50168              
==========================================
- Hits        45778    45769       -9     
- Misses       4390     4399       +9
Flag Coverage Δ
#multiple 89.04% <ø> (ø) ⬆️
#single 40.27% <ø> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.75% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5dd2ea0...7bb3437. Read the comment docs.

@gfyoung gfyoung added the Internals Related to non-user accessible pandas implementation label Oct 23, 2017
@@ -830,6 +830,7 @@ Other API Changes
- Restricted DateOffset keyword arguments. Previously, ``DateOffset`` subclasses allowed arbitrary keyword arguments which could lead to unexpected behavior. Now, only valid arguments will be accepted. (:issue:`17176`).
- Pandas no longer registers matplotlib converters on import. The converters
will be registered and used when the first plot is draw (:issue:`17710`)
- ``NaT`` division with :class:`datetime.timedelta` will now return NaN instead of raising (:issue:`17876`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-tick the NaN.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what is the rationale for returning NaN ? Why not return NaT instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also occurs to me that you might not need a whatsnew given that this is internal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-tick the NaN.

Just pushed a fix.

Also, what is the rationale for returning NaN ? Why not return NaT instead?

This is just taking behavior that currently applies to Timedelta and applying the same to timedelta.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm...seems a little non-intuitive to me, but then again, I'm not going to push changing the norm without getting feedback from other maintainers:

@jreback @jorisvandenbossche ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea is that in this context NaT is ducking as a Timedelta, so Y = NaT / Timedelta(X) is solving for Timedelta(X) * Y = NaT --> Y = np.nan

Copy link
Member

@gfyoung gfyoung Oct 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Right, that makes sense. Leave it be then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that seems to make sense to me, similar as:

In [5]: np.nan / 5
Out[5]: nan

And also this is how pd.NaT / pd.Timedelta(..) is already working? In that case I would rather call it a bug fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also this is how pd.NaT / pd.Timedelta(..) is already working?

Yes.

@jreback jreback added the Bug label Oct 23, 2017
@jreback jreback added this to the 0.21.1 milestone Oct 23, 2017
@jreback
Copy link
Contributor

jreback commented Oct 23, 2017

will be for 0.21.1, we haven't pushed the whatsnew yet, so will need to update then.

@jbrockmendel
Copy link
Member Author

will be for 0.21.1, we haven't pushed the whatsnew yet, so will need to update then.

OK. Does that mean I need to something now or just be patient?

@gfyoung
Copy link
Member

gfyoung commented Oct 24, 2017

@jbrockmendel : Just hold on for the time being. This PR is good to go otherwise I think. We'll ping you once it's added, or if we don't, ping us about it.

@@ -830,6 +830,7 @@ Other API Changes
- Restricted DateOffset keyword arguments. Previously, ``DateOffset`` subclasses allowed arbitrary keyword arguments which could lead to unexpected behavior. Now, only valid arguments will be accepted. (:issue:`17176`).
- Pandas no longer registers matplotlib converters on import. The converters
will be registered and used when the first plot is draw (:issue:`17710`)
- ``NaT`` division with :class:`datetime.timedelta` will now return ``NaN`` instead of raising (:issue:`17876`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so will move to 0.21.1 when its available

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move to 0.22.0 other api changes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Out of curiosity, why 0.22.0 instead of 0.21.1?

@jreback
Copy link
Contributor

jreback commented Oct 27, 2017

@jbrockmendel if you would rebase

@jbrockmendel jbrockmendel mentioned this pull request Oct 27, 2017
59 tasks
@jreback jreback modified the milestones: 0.21.1, 0.22.0 Oct 27, 2017
@jreback
Copy link
Contributor

jreback commented Oct 27, 2017

ok ping on green.

@jreback jreback merged commit 4489389 into pandas-dev:master Oct 28, 2017
@jreback
Copy link
Contributor

jreback commented Oct 28, 2017

thanks

@jbrockmendel jbrockmendel deleted the tslibs-timedeltas6 branch October 28, 2017 04:50
peterpanmj pushed a commit to peterpanmj/pandas that referenced this pull request Oct 31, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants