question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Histogram of CuDF with groupby fails

See original GitHub issue

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)

hvplot 0.6 bokeh 2.2 cudf 0.15.0a+4572.gafb3928f6 (should be equiv with 0.15 or 0.16)

Description of expected behavior and the observed behavior

hvplot.hist on a CuDF Datframe fails if a by argument is supplied (works without a by argument)

Complete, minimal, self-contained example code that reproduces the issue

import cudf
import hvplot.cudf

df = cudf.DataFrame({"x": [1,2,1,3,4,5], "v": [0,0,0, 1,1,1]})
df.hvplot.hist(y="x", by="v")

Edit: updated “v” column to not be string since CuDF does not support string arrays yet

Stack traceback and/or browser JavaScript console output

TypeError: Series object is not iterable. Consider using `.to_arrow()`, `.to_pandas()` or `.values_host` if you wish to iterate over the values.
``` --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-187-76dbabf783f0> in <module> 1 df = cudf.DataFrame({"x": [1,2,1,3,4,5], "v": list("abaabb")}) ----> 2 df.hvplot.hist(y="x", by="v")

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/hvplot/plotting/core.py in hist(self, y, by, **kwds) 399 The HoloViews representation of the plot. 400 “”" –> 401 return self(kind=‘hist’, x=None, y=y, by=by, **kwds) 402 403 def kde(self, y=None, by=None, **kwds):

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/hvplot/plotting/core.py in call(self, x, y, kind, **kwds) 70 return pn.panel(plot, **panel_dict) 71 —> 72 return self._get_converter(x, y, kind, **kwds)(kind, x, y) 73 74 def _get_converter(self, x=None, y=None, kind=None, **kwds):

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/hvplot/converter.py in call(self, kind, x, y) 1022 dataset = Dataset(data) 1023 dataset = dataset.redim(**self._redim) -> 1024 obj = method(x, y) 1025 obj._dataset = dataset 1026

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/hvplot/converter.py in hist(self, x, y, data) 1472 if self.by: 1473 hist = hists = histogram( -> 1474 ds.groupby(self.by), dimension=y, **hist_opts 1475 ) 1476 hist = hists.last

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/holoviews/core/data/init.py in pipelined_fn(*args, **kwargs) 214 215 try: –> 216 result = method_fn(*args, **kwargs) 217 218 op = method_op.instance(

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/holoviews/core/data/init.py in groupby(self, dimensions, container_type, group_type, dynamic, **kwargs) 969 970 return self.interface.groupby(self, dim_names, container_type, –> 971 group_type, **kwargs) 972 973 def transform(self, *args, **kwargs):

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/holoviews/core/data/cudf.py in groupby(cls, dataset, dimensions, container_type, group_type, **kwargs) 164 165 # Find all the keys along supplied dimensions –> 166 keys = product(*(dataset.data[dimensions[0]].unique() for d in dimensions)) 167 168 # Iterate over the unique entries applying selection masks

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/cudf/core/series.py in iter(self) 801 802 def iter(self): –> 803 cudf.utils.utils.raise_iteration_error(obj=self) 804 805 iteritems = iter

~/anaconda/envs/cuxfdev/lib/python3.7/site-packages/cudf/utils/utils.py in raise_iteration_error(obj) 435 def raise_iteration_error(obj): 436 raise TypeError( –> 437 f"{obj.class.name} object is not iterable. " 438 f"Consider using .to_arrow(), .to_pandas() or .values_host " 439 f"if you wish to iterate over the values."

TypeError: Series object is not iterable. Consider using .to_arrow(), .to_pandas() or .values_host if you wish to iterate over the values.

</details>

#### Screenshots or screencasts of the bug in action

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Sep 21, 2020

@philippjfr can you move this to holoviews?

0reactions
maximltcommented, Oct 14, 2022

It seems like this was fixed but never closed 🙃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected results for Plotting a Histogram of a GroupBy ...
A histogram would be used to display the frequency (count) of some measure while fitting a range of measures into a specified number...
Read more >
Prototyping Faster with the Newest UDF Enhancements in the ...
This post highlights helpful new cuDF features that allow you to think about a single row of data and write code faster.
Read more >
cudf.DataFrame.groupby - RAPIDS Docs
Used to determine the groups for the groupby. If by is a function, it's called on each value of the object's index. If...
Read more >
[Solved]-How do I unstack these three histogram columns? Position ...
Coding example for the question How do I unstack these three histogram columns? Position Argument Fails-Pandas,Python.
Read more >
Releases — HoloViews v1.15.3
Improve error message for hv.opts without a plotting backend (#5494) ... Various Dask and cuDF histogram fixes (#4691). Fix handling of custom matplotlib ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found