-
-
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
Conversation
Hello @5hirish! Thanks for submitting the PR.
|
Ran tests locally |
there is custom datatype
|
For failures like 1, you'll need to update
No. Int64 and int64 are different. Int64 is our integer-NA dtype. You'll need to update the Sparse tests as well. you'll need to do |
All tests and checks have passed except for one where I got this error although all tests have passed |
isort error: https://travis-ci.org/pandas-dev/pandas/jobs/447147983#L2772 Make sure to merge master. LMK if you need help fixing it. |
pandas/tests/arrays/test_integer.py
Outdated
"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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean this
a)
result = df.groupby("A").op()
assert result.dtypes['C'].name == 'Int64'
b) or do you mean that I should construct the expected as:
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)
Because in b) the expected constructed dataframe converts Int64
to int64
.
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.
Because in b) the expected constructed dataframe converts Int64 to int64
The "Int64" (capital "I") is a pandas thing. You need
"C": integer_array([1, 3], dtype="Int64")
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.
the 2nd. we want to construct the resulting frame and compare
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.
Why was this marked resolved? Am I missing the expected
and the tm.assert_frame_equal
?
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.
No, you are correct, I missed that one...
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.
This will need a release note in whatsnew/0.24.0.txt
pandas/tests/arrays/test_integer.py
Outdated
"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 comment
The reason will be displayed to describe this comment to others. Learn more.
Because in b) the expected constructed dataframe converts Int64 to int64
The "Int64" (capital "I") is a pandas thing. You need
"C": integer_array([1, 3], dtype="Int64")
Did |
@5hirish I think you needed to merge master before running isort. Pretty sure travis tests a merge commit, which may have explained the difference. I merged master and pushed a change. So you'll want to pull before making additional changes. |
Codecov Report
@@ Coverage Diff @@
## master #23318 +/- ##
==========================================
+ Coverage 92.22% 92.23% +<.01%
==========================================
Files 161 161
Lines 51191 51202 +11
==========================================
+ Hits 47210 47225 +15
+ Misses 3981 3977 -4
Continue to review full report at Codecov.
|
8a9a36e
to
fc5d2f2
Compare
pandas/tests/arrays/test_integer.py
Outdated
"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 comment
The reason will be displayed to describe this comment to others. Learn more.
the 2nd. we want to construct the resulting frame and compare
pandas/tests/arrays/test_integer.py
Outdated
"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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this marked resolved? Am I missing the expected
and the tm.assert_frame_equal
?
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.
LGTM. @jreback any other comments?
thanks @5hirish |
git diff upstream/master -u -- "*.py" | flake8 --diff