-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: dropping of nuisance columns for groupby ops #38815 #43674
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
Changes from all commits
803c71a
be37c17
7e25f94
3f98589
74403e1
d170eea
c73d154
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 |
---|---|---|
|
@@ -853,11 +853,6 @@ def test_groupby_multi_corner(df): | |
|
||
def test_omit_nuisance(df): | ||
grouped = df.groupby("A") | ||
|
||
result = grouped.mean() | ||
expected = df.loc[:, ["A", "C", "D"]].groupby("A").mean() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
agged = grouped.agg(np.mean) | ||
exp = grouped.mean() | ||
tm.assert_frame_equal(agged, exp) | ||
|
@@ -876,14 +871,43 @@ def test_omit_nuisance(df): | |
grouped.agg(lambda x: x.sum(0, numeric_only=False)) | ||
|
||
|
||
def test_omit_nuisance_sem(df): | ||
# GH 38774 - sem should work with nuisance columns | ||
@pytest.mark.parametrize( | ||
"agg_function", | ||
["max", "min"], | ||
) | ||
def test_keep_nuisance_agg(df, agg_function): | ||
# GH 38815 | ||
grouped = df.groupby("A") | ||
result = getattr(grouped, agg_function)() | ||
expected = result.copy() | ||
expected.loc["bar", "B"] = getattr(df.loc[df["A"] == "bar", "B"], agg_function)() | ||
expected.loc["foo", "B"] = getattr(df.loc[df["A"] == "foo", "B"], agg_function)() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"agg_function", | ||
["sum", "mean", "prod", "std", "var", "median"], | ||
) | ||
def test_omit_nuisance_agg(df, agg_function): | ||
# GH 38774, GH 38815 | ||
grouped = df.groupby("A") | ||
result = grouped.sem() | ||
expected = df.loc[:, ["A", "C", "D"]].groupby("A").sem() | ||
result = getattr(grouped, agg_function)() | ||
expected = getattr(df.loc[:, ["A", "C", "D"]].groupby("A"), agg_function)() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_omit_nuisance_warnings(df): | ||
# GH 38815 | ||
with tm.assert_produces_warning( | ||
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. what is this warning? why are you adding extra options? 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. This was the warning that you wanted to be asserted. I took away the parameterization now https://github.com/pandas-dev/pandas/pull/43674/checks?check_run_id=3771738681 |
||
FutureWarning, filter_level="always", check_stacklevel=False | ||
): | ||
grouped = df.groupby("A") | ||
result = grouped.skew() | ||
expected = df.loc[:, ["A", "C", "D"]].groupby("A").skew() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_omit_nuisance_python_multiple(three_group): | ||
grouped = three_group.groupby(["A", "B"]) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.