-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add test for #32108 (error with groupby on series with period index) #33105
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 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
74e65a8
Add test for #32108
dbeniamine fb148f5
Typographic improvements in test_groupby.py
daxid a3444fc
Yet again improve typo in test_groupby.py
daxid 0cd603f
Fix linter issues
dbeniamine 35deb44
Black formating
dbeniamine e6f3884
Move test to test_grouping.py
dbeniamine fd3c0db
Conform to PEP8
dbeniamine 4dac36a
Merge branch 'master' of https://github.com/pandas-dev/pandas
dbeniamine 7fbfb65
Merge branch 'master' of https://github.com/pandas-dev/pandas
dbeniamine 4379fe3
New modifications for PR
dbeniamine ad9fac6
Change index name
dbeniamine 408da64
Rename period_series
dbeniamine 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
from pandas.errors import PerformanceWarning | ||
|
||
import pandas as pd | ||
from pandas import DataFrame, Index, MultiIndex, Series, Timestamp, date_range, read_csv | ||
from pandas import DataFrame, Index, MultiIndex, Series, Timestamp, date_range, period_range, read_csv | ||
import pandas._testing as tm | ||
from pandas.core.base import SpecificationError | ||
import pandas.core.common as com | ||
|
@@ -2057,3 +2057,15 @@ def test_groups_repr_truncates(max_seq_items, expected): | |
|
||
result = df.groupby(np.array(df.a)).groups.__repr__() | ||
assert result == expected | ||
|
||
|
||
def test_groupby_period_index(): | ||
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. Add the issue number here:
|
||
periods = 2 | ||
index = period_range(start='2018-01', periods=periods, freq='M') | ||
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. Looks like you haven't run |
||
periodSerie = Series(range(periods), index=index) | ||
periodSerie.index.name = 'Month' | ||
result = periodSerie.groupby(periodSerie.index.month).sum() | ||
|
||
expected = pd.Series(range(0, periods), index=range(1, periods + 1)) | ||
expected.index.name = periodSerie.index.name | ||
tm.assert_series_equal(result, expected) |
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.
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 move this under test_grouper_index_types (same file). ping on green.
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.
The function
test_grouper_index_types
is in the filepandas/tests/groupby/test_grouping.py
our test is inpandas/tests/groupby/test_groupby.py
, do you want us to move our test totest_grouping.py
?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.
yes pls move this
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.
done