-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG - remove scaling multiplier from Period
diff result
#23915
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
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
377f6d1
BUG/TST - do not multiply period diff result by freq scaling factor
sds9995 b9fe48a
TST - reference issue number in test
sds9995 c262453
CLN - pep8 adherence
sds9995 364d4a9
DOC - reference issue in whatsnew
sds9995 713484c
Revert "DOC - reference issue in whatsnew"
sds9995 d0a5afe
TST - parameterize test
sds9995 7ebe407
DOC - reference issue in whatsnew
sds9995 e8b4c4a
BUG - account for freq kwds
sds9995 9ad13d8
TST - move non standard freq period diff test and test various keywords
sds9995 a38ba5a
BUG/CLN - fix periodindex/array diff, and provide base method for off…
sds9995 cd7bb21
TST/DOC - split tick and offset tests and fix whatsnew
sds9995 9a369a6
TST - add periodindex diff fix tests
sds9995 c8f36b9
DOC - add docstrings and GH references
sds9995 3206144
DOC - additional explanation of code
sds9995 4b83c3a
Merge branch 'master' into bug/period_diff
sds9995 1db7bb0
Merge branch 'master' into bug/period_diff
sds9995 c9a83d6
CLN - reorganize test
sds9995 7c4e3e6
TST - update tests to account for existing bug
sds9995 c128a1f
TST - move tick fixture to pandas/conftest
sds9995 e6d35e6
CLN - fix linting error
sds9995 ae189ea
DOC - add more detail about this fixs behavior in the whatsnew
sds9995 8aaf19e
DOC - fix issue reference
sds9995 9ed3629
DOC - fix spacing
sds9995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from pandas.core import ops | ||
from pandas import Period, PeriodIndex, period_range, Series | ||
from pandas.tseries.frequencies import to_offset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so we can't do this, instead move the tick_classes fixture to pandas/conftest.py. I think everything should still work There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
from pandas.tests.tseries.offsets.conftest import tick_classes | ||
|
||
|
||
# ------------------------------------------------------------------ | ||
|
@@ -370,6 +371,41 @@ def test_parr_sub_pi_mismatched_freq(self, box_with_array): | |
with pytest.raises(IncompatibleFrequency): | ||
rng - other | ||
|
||
@pytest.mark.parametrize('n', [1, 2, 3, 4]) | ||
def test_sub_n_gt_1_ticks(self, tick_classes, n): | ||
# GH 23878 | ||
p1_d = '19910905' | ||
p2_d = '19920406' | ||
p1 = pd.PeriodIndex([p1_d], freq=tick_classes(n)) | ||
p2 = pd.PeriodIndex([p2_d], freq=tick_classes(n)) | ||
|
||
expected = (pd.PeriodIndex([p2_d], freq=p2.freq.base) | ||
- pd.PeriodIndex([p1_d], freq=p1.freq.base)) | ||
|
||
tm.assert_index_equal((p2 - p1), expected) | ||
|
||
@pytest.mark.parametrize('n', [1, 2, 3, 4]) | ||
@pytest.mark.parametrize('offset, kwd_name', [ | ||
(pd.offsets.YearEnd, 'month'), | ||
(pd.offsets.QuarterEnd, 'startingMonth'), | ||
(pd.offsets.MonthEnd, None), | ||
(pd.offsets.Week, 'weekday') | ||
]) | ||
def test_sub_n_gt_1_offsets(self, offset, kwd_name, n): | ||
# GH 23878 | ||
kwds = {kwd_name: 3} if kwd_name is not None else {} | ||
p1_d = '19910905' | ||
p2_d = '19920406' | ||
freq = offset(n, normalize=False, **kwds) | ||
p1 = pd.PeriodIndex([p1_d], freq=freq) | ||
p2 = pd.PeriodIndex([p2_d], freq=freq) | ||
|
||
result = p2 - p1 | ||
expected = (pd.PeriodIndex([p2_d], freq=freq.base) | ||
- pd.PeriodIndex([p1_d], freq=freq.base)) | ||
|
||
tm.assert_index_equal(result, expected) | ||
|
||
# ------------------------------------------------------------- | ||
# Invalid Operations | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.