-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: groupby-reindex on DTI #33638
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
TST: groupby-reindex on DTI #33638
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -901,3 +901,17 @@ def fn(x): | |
name="col2", | ||
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
|
||
def test_apply_reindex_values(): | ||
# GH: 26209 | ||
values = [1, 2, 3, 4] | ||
indices = [1, 1, 2, 2] | ||
df = pd.DataFrame( | ||
{"group": ["Group1", "Group2"] * 2, "value": values}, index=indices | ||
) | ||
srs_exp = pd.Series(values, index=indices, name="value") | ||
srs_grouped = df.groupby("group").value.apply( | ||
lambda x: x.reindex(np.arange(x.index.min(), x.index.max() + 1)) | ||
) | ||
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. theres a lot going on here. can you break this up into multiple lines and comment on which one used to be a problem 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. I wrote a seperate apply function and gave a little bit more background in the comments. Let me know if there is still somthing missing |
||
tm.assert_series_equal(srs_exp, srs_grouped) | ||
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. can you call these 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 |
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.
a few words about what the bug was would be hepful
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