-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Add a test for agg std #52371
Conversation
@@ -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]}) |
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 use the exact DataFrame from the issue?
|
||
def test_agg_std(): | ||
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) | ||
std = df.agg(np.std) |
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.
std = df.agg(np.std) | |
expected = df.agg(np.std) |
Could you also compare df.agg([np.std])
?
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.
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)
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.
Just asking to add a test to also check the result of df.agg([np.std])
as well
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) | ||
std = df.agg(np.std) | ||
expected = pd.Series({'A': 1.0, 'B': 1.0}, dtype=float) | ||
assert std.equals(expected) |
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.
assert std.equals(expected) | |
tm.assert_series_equal(result, expected) |
Can you move the test to |
I believe that this will fulfill your request, but please let me know if there is anything else I can do. @mroeschke |
tm.assert_series_equal(result, expected) | ||
|
||
result = df.agg([np.std]) | ||
assert isinstance(result, pd.DataFrame) |
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.
Please construct the expected result and use tm.assert_frame_equal
Looks like a few of the code check builds are failing |
@mroeschke , I have fixed the code checks that were failing, and I have constructed the tests as your instructions. |
Awesome! Thanks @steliospetrakis02 |
You're welcome! I thank you for your guidance and assistance as I take my first steps into contributing to pandas |
* Add a test for agg std * move the test as requested and added one more test for df.agg([np.std]) * fix second test * fix format * Update test_aggregate.py * Update test_frame_apply.py
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.I believe that this test ensures the expected output. Let me know if you have any questions or concerns.