Skip to content

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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

df = DataFrame({"A": [1] * 10})
df = df.iloc[:, :5]
expected = np.array([10, 1])
tm.assert_equal(np.array(df.shape), expected)
Copy link
Member

@rhshadrach rhshadrach Dec 28, 2020

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).



class TestILocErrors:
# NB: this test should work for _any_ Series we can pass as
Expand Down