-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pd.concat does not drop DatetimeIndex.freq when result is monotonic with even spacing #25796
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
Codecov Report
@@ Coverage Diff @@
## master #25796 +/- ##
==========================================
- Coverage 91.26% 91.26% -0.01%
==========================================
Files 173 173
Lines 52982 52983 +1
==========================================
Hits 48356 48356
- Misses 4626 4627 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #25796 +/- ##
==========================================
+ Coverage 91.48% 91.48% +<.01%
==========================================
Files 175 175
Lines 52877 52879 +2
==========================================
+ Hits 48372 48374 +2
Misses 4505 4505
Continue to review full report at Codecov.
|
pandas/core/indexes/datetimelike.py
Outdated
|
||
# GH 3232: If the concat result is evenly spaced, we can retain the | ||
# original frequency | ||
is_diff_evenly_spaced = len(np.unique(np.diff(new_data))) == 1 |
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 we have something that does this in tseries.frequencies, can you see / use it?
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.
Checked in tseries.frequencies
but didn't find anything. We have is_monotonic
functions but it doesn't check for even spacing.
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.
you can use unique_1d here (should be faster), though not a big deal. worth moving this actually to tseries.frequencies as a named function?
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 looks a bit like unique_deltas
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.
Thanks @jbrockmendel. Exactly what I needed.
pandas/core/indexes/datetimelike.py
Outdated
|
||
# GH 3232: If the concat result is evenly spaced, we can retain the | ||
# original frequency | ||
is_diff_evenly_spaced = len(np.unique(np.diff(new_data))) == 1 |
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.
you can use unique_1d here (should be faster), though not a big deal. worth moving this actually to tseries.frequencies as a named function?
lgtm. merge on green. |
thanks @mroeschke |
git diff upstream/master -u -- "*.py" | flake8 --diff