Skip to content

Plotting ExtensionArrays #27118

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
wants to merge 8 commits into from
Closed
Changes from 4 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
13 changes: 8 additions & 5 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,14 @@ def _compute_plot_data(self):
# GH16953, _convert is needed as fallback, for ``Series``
# with ``dtype == object``
data = data._convert(datetime=True, timedelta=True)
numeric_data = data.select_dtypes(include=[np.number,
"datetime",
"datetimetz",
"timedelta"])

# GH26173, don't filter out numeric extension types
# Numeric categorical data gets caught by including np.number
# in select_dtypes
numeric_dtypes = [dtype for dtype in set(data.dtypes)
if hasattr(dtype, "_is_numeric") and
dtype._is_numeric and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than this i would fix select_dtypes to understand the is_numeric flag of the EA dtype; it’s possible that actually need something more because for example datetimes are not numeric but are allowed for plotting

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this should be addressed in select_dtypes rather than here.

dtype.name is not "category"]
numeric_data = data.select_dtypes(include=[np.number] + numeric_dtypes)
try:
is_empty = numeric_data.empty
except AttributeError:
Expand Down