Skip to content

Add a test for agg std #52371

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 6 commits into from
Apr 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,3 +1577,9 @@ def test_agg_groupings_selection():
)
expected = DataFrame({"b": [6, 4], "c": [11, 7]}, index=index)
tm.assert_frame_equal(result, expected)

def test_agg_std():
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
Copy link
Member

@mroeschke mroeschke Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the exact DataFrame from the issue?

std = df.agg(np.std)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std = df.agg(np.std)
expected = df.agg(np.std)

Could you also compare df.agg([np.std])?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mroeschke, I'm sorry but I'm not sure what you are asking. Do you want me to check the type of class? e.g (pandas.core.series.Series)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking to add a test to also check the result of df.agg([np.std]) as well

expected = pd.Series({'A': 1.0, 'B': 1.0}, dtype=float)
assert std.equals(expected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert std.equals(expected)
tm.assert_series_equal(result, expected)