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

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

Open
LiamConnors opened this issue Nov 13, 2024 · 2 comments · May be fixed by #4878
Open
Assignees
Labels
documentation written for humans P1 needed for current cycle

Comments

@LiamConnors
Copy link
Member

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.
@gvwilson
Copy link
Contributor

Let's document this in the section where we tell people which dataframes we support ("For example, blah blah doesn't work with cuDF yet…" - nothing fancy).

@gvwilson gvwilson added P1 needed for current cycle documentation written for humans labels Nov 13, 2024
@MarcoGorelli
Copy link
Contributor

thanks for spotting this, I think it should be possible to rewrite this without using iter_rows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation written for humans P1 needed for current cycle
Projects
None yet
3 participants