Skip to content
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

handle NaT add/sub in one place #19903

Merged
merged 3 commits into from
Feb 27, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

ATM DatetimeIndex/TimedeltaIndex/PeriodIndex each have special-casing for addition/subtraction of NaT. This checks for NaT up-front and puts all of that logic into add_nat and sub_nat methods.

Also makes another step towards centralizing all of the wrapping of the add/sub ops at the end of __add__ and __sub__.

Should be orthogonal to other outstanding PRs, albeit just barely.

nanos = delta_to_nanoseconds(other)
offset_nanos = delta_to_nanoseconds(offset)
if (nanos % offset_nanos).all() == 0:
return nanos // offset_nanos
Copy link
Member Author

Choose a reason for hiding this comment

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

This block is never reached b/c there is a separate check for np.ndarray before this.

@jreback jreback added Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Feb 26, 2018
@codecov
Copy link

codecov bot commented Feb 26, 2018

Codecov Report

Merging #19903 into master will increase coverage by <.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19903      +/-   ##
==========================================
+ Coverage   91.66%   91.67%   +<.01%     
==========================================
  Files         150      150              
  Lines       48969    48967       -2     
==========================================
+ Hits        44886    44889       +3     
+ Misses       4083     4078       -5
Flag Coverage Δ
#multiple 90.05% <87.5%> (ø) ⬆️
#single 41.85% <31.25%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/timedeltas.py 91.17% <100%> (-0.04%) ⬇️
pandas/core/indexes/period.py 94.65% <100%> (+1.3%) ⬆️
pandas/core/indexes/datetimes.py 95.5% <75%> (-0.11%) ⬇️
pandas/core/indexes/datetimelike.py 96.83% <86.95%> (-0.5%) ⬇️

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 1e4c50a...244bdaa. Read the comment docs.

@jreback jreback added this to the 0.23.0 milestone Feb 27, 2018
@jreback jreback merged commit f4c9d96 into pandas-dev:master Feb 27, 2018
@jreback
Copy link
Contributor

jreback commented Feb 27, 2018

thanks

harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
@jbrockmendel jbrockmendel deleted the idx_nat_ops branch June 22, 2018 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants