Skip to content

icicle, treemap, and sunburst won't work with cuDF when using path parameter (master branch) #4876

@LiamConnors

Description

@LiamConnors

I was running through some testing for cuDF and noted these traces will not work because they use iter_rows() when path parameter is used on the px function.

import plotly.express as px
import numpy as np
df = px.data.gapminder().query("year == 2007")
df = cudf.DataFrame(df)
fig = px.sunburst(df, path=['continent', 'country'], values='pop',
                  color='lifeExp', hover_data=['iso_alpha'],
                  color_continuous_scale='RdBu',
                  color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
fig.show()
[/usr/local/lib/python3.10/dist-packages/plotly/express/_core.py](https://localhost:8080/#) in _check_dataframe_all_leaves(df)
   1859     ).get_column("null_mask")
   1860 
-> 1861     for row_idx, row in zip(
   1862         null_indices_mask, null_mask.filter(null_indices_mask).iter_rows()
   1863     ):

[/usr/local/lib/python3.10/dist-packages/narwhals/series.py](https://localhost:8080/#) in __iter__(self)
   2691 
   2692     def __iter__(self: Self) -> Iterator[Any]:
-> 2693         yield from self._compliant_series.__iter__()
   2694 
   2695     @property

[/usr/local/lib/python3.10/dist-packages/narwhals/_pandas_like/series.py](https://localhost:8080/#) in __iter__(self)
    761 
    762     def __iter__(self: Self) -> Iterator[Any]:
--> 763         yield from self._native_series.__iter__()
    764 
    765     @property

[/usr/local/lib/python3.10/dist-packages/cudf/utils/utils.py](https://localhost:8080/#) in __iter__(self)
    240         information.
    241         """
--> 242         raise TypeError(
    243             f"{self.__class__.__name__} object is not iterable. "
    244             f"Consider using `.to_arrow()`, `.to_pandas()` or `.values_host` "

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

Metadata

Metadata

Assignees

Labels

P1needed for current cycledocumentationwritten for humans

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions