-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: groupby agg fails silently with mixed dtypes #43213
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 6 commits
91aa285
9b9b7af
d968e57
46a29e0
195db31
16e28db
854ecda
7dd27f3
309ee59
8d1bfb1
41471aa
3647f53
d6992e5
ab1fd87
23d2989
9039124
d75c57b
89a6bc7
64ca85a
8a0f5fe
4ae0d6b
ac51170
572f23c
183f245
62b5aac
625a751
9b0acd7
4b4618a
265b3bb
a55211a
753c7df
de86f72
2a29451
a37f1f9
00838be
a04d021
c9d6658
5db7155
5ccf385
9afd465
600b71e
fe13278
1aaf326
4ba8511
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 |
---|---|---|
|
@@ -2419,3 +2419,26 @@ def test_rolling_wrong_param_min_period(): | |
result_error_msg = r"__init__\(\) got an unexpected keyword argument 'min_period'" | ||
with pytest.raises(TypeError, match=result_error_msg): | ||
test_df.groupby("name")["val"].rolling(window=2, min_period=1).sum() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
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. move these to pandas/tests/groupby/aggregate/test_aggreagte.py (or maybe test_cython) see where similar are. |
||
"func, expected, dtype, result_dtype", | ||
[ | ||
("sum", [5, 7, 9], int, "int64"), | ||
("std", [4.5 ** 0.5] * 3, int, float), | ||
("var", [4.5] * 3, int, float), | ||
("sum", [5, 7, 9], "Int64", "Int64"), | ||
# result_dtype should ideally be Float64 | ||
debnathshoham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
("std", [4.5 ** 0.5] * 3, "Int64", float), | ||
("var", [4.5] * 3, "Int64", "Float64"), | ||
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 actually casts to Float64? what were the results in 1.2.5? we should match them. 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. Yeah. 1.2.5 was 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. great, yeah we want to have an exact match to 1.2.5; this can be changed going forwawrd for 1.4, but not on a regression patch. |
||
], | ||
) | ||
def test_multiindex_groupby(func, expected, dtype, result_dtype): | ||
# GH#43209 | ||
df = DataFrame( | ||
[[1, 2, 3, 4, 5, 6]] * 3, | ||
columns=MultiIndex.from_product([["a", "b"], ["i", "j", "k"]]), | ||
).astype({("a", "j"): dtype, ("b", "j"): dtype}) | ||
result = df.groupby(level=1, axis=1).agg(func) | ||
expected = DataFrame([expected] * 3, columns=["i", "j", "k"], dtype=result_dtype) | ||
tm.assert_frame_equal(result, expected) |
Uh oh!
There was an error while loading. Please reload this page.