-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: GroupBy return EA dtype #23318
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
BUG: GroupBy return EA dtype #23318
Changes from 11 commits
09e8472
27ce828
28b45f2
9243612
9502ba4
14666a1
44287de
d54c743
05eb70c
8ac749d
c1d8416
fc5d2f2
2859c70
07ffcc7
2487fd1
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 |
---|---|---|
|
@@ -650,11 +650,9 @@ def test_preserve_dtypes(op): | |
|
||
# groupby | ||
result = getattr(df.groupby("A"), op)() | ||
expected = pd.DataFrame({ | ||
"B": np.array([1.0, 3.0]), | ||
"C": np.array([1, 3], dtype="int64") | ||
}, index=pd.Index(['a', 'b'], name='A')) | ||
tm.assert_frame_equal(result, expected) | ||
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. fully construct the return frame as in the existing example 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. Do you mean this
b) or do you mean that I should construct the expected as:
Because in b) the expected constructed dataframe converts 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.
The "Int64" (capital "I") is a pandas thing. You need
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. the 2nd. we want to construct the resulting frame and compare 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. Why was this marked resolved? Am I missing the 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. No, you are correct, I missed that one... |
||
|
||
assert result.dtypes['B'].name == 'float64' | ||
assert result.dtypes['C'].name == 'Int64' | ||
|
||
|
||
@pytest.mark.parametrize('op', ['mean']) | ||
|
@@ -673,9 +671,10 @@ def test_reduce_to_float(op): | |
|
||
# groupby | ||
result = getattr(df.groupby("A"), op)() | ||
|
||
expected = pd.DataFrame({ | ||
"B": np.array([1.0, 3.0]), | ||
"C": np.array([1, 3], dtype="float64") | ||
5hirish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"C": integer_array([1, 3], dtype="Int64") | ||
}, index=pd.Index(['a', 'b'], name='A')) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.