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

Path failing with vdims with categorical dtypes #5970

Closed
maximlt opened this issue Nov 2, 2023 · 1 comment · Fixed by #5969
Closed

Path failing with vdims with categorical dtypes #5970

maximlt opened this issue Nov 2, 2023 · 1 comment · Fixed by #5969
Labels
TRIAGE Needs triaging

Comments

@maximlt
Copy link
Member

maximlt commented Nov 2, 2023

Noticed while updating the opensky example.

import numpy as np
import pandas as pd
import holoviews as hv

hv.extension('bokeh')

df = pd.DataFrame({
    'x': np.random.randn(100),
    'y': np.random.randn(100),
    'cat': np.random.choice(['a', 'b', 'c'], 100)
})
df['cat'] = df['cat'].astype('category')
hv.Path(df, ['x', 'y'], vdims=['cat'])

End of the traceback:

File ~/dev/examples/opensky/envs/default/lib/python3.9/site-packages/holoviews/plotting/plot.py:819, in DimensionedPlot._compute_group_range(cls, group, elements, ranges, framewise, axiswise, robust, top_level, prev_frame)
    816     if (isinstance(values, np.ndarray) and values.dtype.kind == 'O' and
    817         all(isinstance(v, (np.ndarray)) for v in values)):
    818         values = np.concatenate(values) if len(values) else []
--> 819     factors = util.unique_array(values)
    820     group_ranges[dim_name]['factors'].append(factors)
    821 group_ranges[dim_name]['id'].append(id(el))

File ~/dev/examples/opensky/envs/default/lib/python3.9/site-packages/holoviews/core/util.py:1222, in unique_array(arr)
   1220         v = pd.Timestamp(v).to_datetime64()
   1221     values.append(v)
-> 1222 return pd.unique(np.asarray(values))

File ~/dev/examples/opensky/envs/default/lib/python3.9/site-packages/pandas/core/algorithms.py:401, in unique(values)
    307 def unique(values):
    308     """
    309     Return unique values based on a hash table.
    310 
   (...)
    399     array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
    400     """
--> 401     return unique_with_mask(values)

File ~/dev/examples/opensky/envs/default/lib/python3.9/site-packages/pandas/core/algorithms.py:440, in unique_with_mask(values, mask)
    438 table = hashtable(len(values))
    439 if mask is None:
--> 440     uniques = table.unique(values)
    441     uniques = _reconstruct_data(uniques, original.dtype, original)
    442     return uniques

File pandas/_libs/hashtable_class_helper.pxi:6968, in pandas._libs.hashtable.StringHashTable.unique()

ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
@maximlt maximlt added the TRIAGE Needs triaging label Nov 2, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
TRIAGE Needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant