Skip to content
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

Improve pd.NA support with inspect_polygon #6362

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion holoviews/core/data/spatialpandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,10 @@ def get_value_array(data, dimension, expanded, keep_index, geom_col,
val = column.iloc[i]
scalar = isscalar(val)
if scalar:
val = np.array([val])
if pd.isna(val):
val = np.array([np.nan])
else:
val = np.array([val])
if not scalar and len(unique_array(val)) == 1:
val = val[:1]
scalar = True
Expand Down
6 changes: 4 additions & 2 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,9 @@ def sanitize(self, name, valid_fn):

def isscalar(val):
"""
Value is scalar or None
Value is scalar, None, or pd.NA
"""
return val is None or np.isscalar(val) or isinstance(val, datetime_types)
return val is None or val is pd.NA or np.isscalar(val) or isinstance(val, datetime_types)


def isnumeric(val):
Expand Down Expand Up @@ -1180,6 +1180,8 @@ def unique_array(arr):
Returns:
A new array of unique values
"""
if arr is pd.NA:
return pd.Series([arr])
if not len(arr):
return np.asarray(arr)

Expand Down