-
-
Notifications
You must be signed in to change notification settings - Fork 409
Open
Description
import numpy as np
import panel as pn
import pandas as pd
import hvplot.pandas
pn.extension()
select = pn.widgets.Select(value="c", options=["c", "c2"])
df = pd.DataFrame({"x": np.linspace(0, 10, 100), "y": np.random.randn(100).cumsum(), "y2": np.random.randn(100).cumsum(), "Category": np.random.choice(["Biology", "Chemistry", "Physics"], 100), "Category 2": np.random.choice(["Biology", "Chemistry", "Physics"], 100)})
df.hvplot.line(x="x", y="y", groupby=select.param.value.rx().rx.pipe(lambda x: "Category" if x == "c" else "Category 2"))---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[9], line 9
7 select = pn.widgets.Select(value="c", options=["c", "c2"])
8 df = pd.DataFrame({"x": np.linspace(0, 10, 100), "y": np.random.randn(100).cumsum(), "y2": np.random.randn(100).cumsum(), "Category": np.random.choice(["Biology", "Chemistry", "Physics"], 100), "Category 2": np.random.choice(["Biology", "Chemistry", "Physics"], 100)})
----> 9 df.hvplot.line(x="x", y="y", groupby=select.param.value.rx().rx.pipe(lambda x: "Category" if x == "c" else "Category 2"))
File ~/repos/hvplot/hvplot/plotting/core.py:372, in hvPlotTabular.line(self, x, y, **kwds)
275 def line(self, x=None, y=None, **kwds):
276 """
277 The `line` plot connects the points with a continuous curve.
278
(...)
370 - Wiki: https://en.wikipedia.org/wiki/Line_chart
371 """
--> 372 return self(x, y, kind='line', **kwds)
File ~/repos/hvplot/hvplot/plotting/core.py:95, in hvPlotBase.__call__(self, x, y, kind, **kwds)
92 plot = self._get_converter(x, y, kind, **kwds)(kind, x, y)
93 return pn.panel(plot, **panel_dict)
---> 95 return self._get_converter(x, y, kind, **kwds)(kind, x, y)
File ~/repos/hvplot/hvplot/converter.py:1859, in HoloViewsConverter.__call__(self, kind, x, y)
1856 dataset = redim_(dataset, **self._redim)
1858 if groups:
-> 1859 datasets = dataset.groupby(groups, dynamic=self.dynamic)
1860 if len(zs) > 1:
1861 dimensions = [Dimension(self.group_label, values=zs)] + datasets.kdims
File ~/miniconda3/envs/lumen/lib/python3.12/site-packages/holoviews/core/data/__init__.py:201, in PipelineMeta.pipelined.<locals>.pipelined_fn(*args, **kwargs)
198 inst._in_method = True
200 try:
--> 201 result = method_fn(*args, **kwargs)
202 if PipelineMeta.disable:
203 return result
File ~/miniconda3/envs/lumen/lib/python3.12/site-packages/holoviews/core/data/__init__.py:1059, in Dataset.groupby(self, dimensions, container_type, group_type, dynamic, **kwargs)
1056 if not dimensions: dimensions = self.dimensions('key', True)
1057 if group_type is None: group_type = type(self)
-> 1059 dimensions = [self.get_dimension(d, strict=True) for d in dimensions]
1060 dim_names = [d.name for d in dimensions]
1062 if dynamic:
File ~/miniconda3/envs/lumen/lib/python3.12/site-packages/holoviews/core/dimension.py:1020, in Dimensioned.get_dimension(self, dimension, default, strict)
1004 """Get a Dimension object by name or index.
1005
1006 Parameters
(...)
1017 Dimension object for the requested dimension or default
1018 """
1019 if dimension is not None and not isinstance(dimension, (int, str, Dimension)):
-> 1020 raise TypeError('Dimension lookup supports int, string, '
1021 'and Dimension instances, cannot lookup '
1022 f'Dimensions using {type(dimension).__name__} type.')
1023 all_dims = self.dimensions()
1024 if isinstance(dimension, int):
TypeError: Dimension lookup supports int, string, and Dimension instances, cannot lookup Dimensions using rx type.```Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels