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

Conversation

luijkr
Copy link

@luijkr luijkr commented Dec 28, 2020

Added a test to ensure .iloc does not truncate data for a single-column dataframe with an extension array, as discussed in GH30263.

@pep8speaks
Copy link

pep8speaks commented Dec 28, 2020

Hello @luijkr! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-12-28 14:49:04 UTC

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

@@ -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

@jreback jreback added ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite labels Dec 28, 2020
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Jan 28, 2021
@jreback
Copy link
Contributor

jreback commented Feb 11, 2021

closing as stale. if you want to continue, pls ping and can re-open.

@jreback jreback closed this Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves Output-Formatting __repr__ of pandas objects, to_string Stale Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iloc erroneously truncates underlying data for timestamps with timezone
4 participants