Skip to content

[#33770] bug fix to prevent ExtensionArrays from crashing Series.__repr__() #33771

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

Merged
merged 6 commits into from
May 1, 2020

Conversation

frreiss
Copy link
Contributor

@frreiss frreiss commented Apr 24, 2020

This pull request fixes a bug in GenericArrayFormatter that caused a crash when rendering arrays of arrays. This problem causes Series.__repr__() to fail with certain extension types; see #33770 for more information.

The root cause is this line:

1231       is_float_type = lib.map_infer(vals, is_float) & notna(vals)

The call to notna() here returns a 2D array if vals is a 2D array, while lib.map_infer(vals, is_float) returns a 1D array if vals is a 2D array.

In addition to fixing that line, this PR also adds tests for the issue.

@jreback jreback added Bug ExtensionArray Extending pandas with custom dtypes or arrays. Output-Formatting __repr__ of pandas objects, to_string labels Apr 24, 2020
@frreiss
Copy link
Contributor Author

frreiss commented Apr 27, 2020

Thanks for the prompt review! I've pushed some updates to this branch which should hopefully address the review comments.

@jreback jreback added this to the 1.1 milestone May 1, 2020
@jreback
Copy link
Contributor

jreback commented May 1, 2020

lgtm. running CI now. merge on green.

@jreback jreback merged commit 911e19b into pandas-dev:master May 1, 2020
rhshadrach pushed a commit to rhshadrach/pandas that referenced this pull request May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: ExtensionArrays whose elements are non-numeric numpy arrays crash Series.__repr__()
2 participants