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
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,9 @@ def is_numeric_dtype(arr_or_dtype):
>>> is_numeric_dtype(np.array([], dtype=np.timedelta64))
False
"""

if is_extension_array_dtype(arr_or_dtype):
dtype = getattr(arr_or_dtype, 'dtype', arr_or_dtype)
return dtype._is_numeric
return _is_dtype_type(
arr_or_dtype, classes_and_not_datetimelike(np.number, np.bool_))

Expand Down
17 changes: 15 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
is_bool_dtype, is_datetime64_any_dtype, is_datetime64tz_dtype,
is_dict_like, is_dtype_equal, is_extension_array_dtype, is_extension_type,
is_float_dtype, is_integer, is_integer_dtype, is_iterator, is_list_like,
is_named_tuple, is_nested_list_like, is_object_dtype, is_scalar,
is_sequence, needs_i8_conversion)
is_named_tuple, is_nested_list_like, is_numeric_dtype, is_object_dtype,
is_scalar, is_sequence, needs_i8_conversion)
from pandas.core.dtypes.generic import (
ABCDataFrame, ABCIndexClass, ABCMultiIndex, ABCSeries)
from pandas.core.dtypes.missing import isna, notna
Expand Down Expand Up @@ -3265,6 +3265,19 @@ def _get_info_slice(obj, indexer):
for dtypes in (include, exclude):
invalidate_string_dtypes(dtypes)

def add_extension_types(dtypes, search_dtype, func):
"""Adds bool or numeric extension types to include/exclude"""
extension_dtypes = [dtype.type for dtype in self.dtypes
if is_extension_array_dtype(dtype) and
func(dtype)]
if search_dtype in dtypes:
return frozenset(dtypes.union(extension_dtypes))
else:
return dtypes
include = add_extension_types(include, np.number, is_numeric_dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand this. Are you unconditionally adding adding an EA if it's considered numeric here?

exclude = add_extension_types(exclude, np.number, is_numeric_dtype)
include = add_extension_types(include, np.bool_, is_bool_dtype)
exclude = add_extension_types(exclude, np.bool_, is_bool_dtype)
# can't both include AND exclude!
if not include.isdisjoint(exclude):
raise ValueError('include and exclude overlap on {inc_ex}'.format(
Expand Down