-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Iloc truncates single-column dataframe with extension arrays #38750
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
Iloc truncates single-column dataframe with extension arrays #38750
Conversation
df = DataFrame({"A": [1] * 10}) | ||
df = df.iloc[:, :5] | ||
expected = np.array([10, 1]) | ||
tm.assert_equal(np.array(df.shape), 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.
I think the issue only appears for ExtensionArray. I'd guess that the behavior you're testing for here is, in some shape or form, tested for already, just not with an ExtensionArray. Can you check?
Also, as reported in the original issue, df.shape
returns the expected result but df.values.shape
does not. Both should be tested (again, for EAs).
@@ -875,6 +875,13 @@ def test_iloc_setitem_dictionary_value(self): | |||
expected = DataFrame({"x": [1, 9], "y": [2.0, 99.0]}) | |||
tm.assert_frame_equal(df, expected) | |||
|
|||
def test_iloc_truncate_data_wrong_axis_single_column(self): | |||
# GH30263 |
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.
also can you add the example from the OP exactly
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
closing as stale. if you want to continue, pls ping and can re-open. |
Added a test to ensure .iloc does not truncate data for a single-column dataframe with an extension array, as discussed in GH30263.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff