Closed hakim3189 closed 8 months ago
Hi @hakim3189, can you please post the versions of cuxfilter, cudf and numpy you are using?
herewith the version cuxfilter version: 23.10.00 cudf version: 23.10.02 numpy version: 1.24.4
Hey @hakim3189, I was not able to reproduce the error on the latest stable release. Can you please give it a try on the version 23.12.* for cudf and cuxfilter?
ok i will try to update cudf and cuxfilter first
hey @AjayThorve , recently i already update my version. herewith my latest version cuxfilter version: 23.12.00 cudf version: 23.12.01 numpy version: 1.23.4
but somehow it still produce this error
AttributeError Traceback (most recent call last) Cell In[88], line 1 ----> 1 d1 = cux_df.dashboard([chart1, chart2],sidebar=[chart3,chart4],layout=cuxfilter.layouts.feature_and_base, theme=cuxfilter.themes.rapids_dark) 2 #[chart1, chart3, chart4], sidebar=[chart2], layout=cuxfilter.layouts.feature_and_double_base, title='Auto Accident Dataset'
File ~/miniconda3/envs/rapids-23.12/lib/python3.10/site-packages/cuxfilter/dataframe.py:236, in DataFrame.dashboard(self, charts, sidebar, layout, theme, title, data_size_widget, warnings, layout_array) 233 if notebook_assets.pn.config.js_files == {}: 234 notebook_assets.load_notebook_assets() --> 236 return DashBoard( 237 charts=charts, 238 sidebar=sidebar, 239 dataframe=self, 240 layout=layout, 241 theme=theme, 242 title=title, 243 data_size_widget=data_size_widget, 244 show_warnings=warnings, 245 layout_array=layout_array, 246 )
File ~/miniconda3/envs/rapids-23.12/lib/python3.10/site-packages/cuxfilter/dashboard.py:186, in DashBoard.init(self, charts, sidebar, dataframe, layout, theme, title, data_size_widget, show_warnings, layout_array) 184 for chart in sidebar: 185 if chart.is_widget: --> 186 chart.initiate_chart(self) 187 chart._initialized = True 188 self._sidebar[chart.name] = chart
File ~/miniconda3/envs/rapids-23.12/lib/python3.10/site-packages/cuxfilter/charts/panel_widgets/plots.py:334, in MultiChoice.initiate_chart(self, dashboard_cls) 328 self.min_value, self.max_value = get_min_max( 329 dashboard_cls._cuxfilter_df.data, self.x 330 ) 331 self.source = dashboard_cls._cuxfilter_df.data[self.x].reset_index( 332 drop=True 333 ) --> 334 self.calc_list_of_values(dashboard_cls._cuxfilter_df.data) 335 self.generate_widget() 336 self.add_events(dashboard_cls)
File ~/miniconda3/envs/rapids-23.12/lib/python3.10/site-packages/cuxfilter/charts/panel_widgets/plots.py:347, in MultiChoice.calc_list_of_values(self, data) 344 if isinstance(data, dask_cudf.core.DataFrame): 345 self.list_of_values = self.list_of_values.compute() --> 347 self.list_of_values = self.list_of_values.to_pandas().tolist() 349 if len(self.list_of_values) > 500: 350 print( 351 """It is not recommended to use a column with 352 so many different values for MultiChoice menu""" 353 )
AttributeError: 'ndarray' object has no attribute 'to_pandas'
Hey @hakim3189 this is a bit weird, can you get the following working in your enviroment?
import cudf
df = cudf.DataFrame({"a":[1,23,3]}, dtype={"a":"int64"})
print(df['a'].unique().to_pandas().tolist())
the error that's raised refers to the above usage of cudf, which on my 23.12 enviroment, works fine. I would need more info into your data. Also I am assuming you are using this with cuDF
and not pandas, is that correct?
hey @AjayThorve
it produce this error in my environment
AttributeError Traceback (most recent call last) Cell In[80], line 3 1 import cudf 2 df = cudf.DataFrame({"a":[1,23,3]}, dtype={"a":"int64"}) ----> 3 print(df['a'].unique().to_pandas().tolist())
AttributeError: 'ndarray' object has no attribute 'to_pandas'
data is originally in pandas but then I convert to cu_df cu_df = cudf.from_pandas(df) cux_df = cuxfilter.DataFrame.from_dataframe(cu_df)
Hey @AjayThorve
Finally I found why this happen
at first herewith my Script : import cuxfilter _%loadext cudf.pandas import pandas as pd from cuxfilter import DataFrame, themes, layouts, charts from cuxfilter.charts import bokeh from cuxfilter.charts import datashader from pathlib import Path import cudf import cuml import datashader as ds import numpy as np import geopandas as gpd import fiona import cuspatial from shapely.geometry import Point, Polygon, MultiPolygon import matplotlib.pyplot as plt
but after I rerun but without this line it work perfectly %load_ext cudf.pandas
Thanks for your help
Thats great @hakim3189. Yeah I think importing cudf after loading cudf.pandas might have cuased the issue. I'll make sure we make it clear on the usage with cudf.pandas in the documentation soon. Feel free to open up an issue if you face any in future.
Hi All,
recently I have problem using widget in cuxfilter, my code always produce "AttributeError: 'ndarray' object has no attribute 'to_pandas'" when using Multiselect & Dropdown but working perfectly when using range_slider. Need guidance why this problem happen and how to solve it.
AttributeError Traceback (most recent call last) Cell In[131], line 1 ----> 1 d1 = cux_df.dashboard([chart1, chart2],sidebar=[chart3,chart4],layout=cuxfilter.layouts.feature_and_base, theme=cuxfilter.themes.rapids_dark) 2 #[chart1, chart3, chart4], sidebar=[chart2], layout=cuxfilter.layouts.feature_and_double_base, title='Auto Accident Dataset'
File ~/miniconda3/envs/rapids-23.10/lib/python3.10/site-packages/cuxfilter/dataframe.py:236, in DataFrame.dashboard(self, charts, sidebar, layout, theme, title, data_size_widget, warnings, layout_array) 233 if notebook_assets.pn.config.js_files == {}: 234 notebook_assets.load_notebook_assets() --> 236 return DashBoard( 237 charts=charts, 238 sidebar=sidebar, 239 dataframe=self, 240 layout=layout, 241 theme=theme, 242 title=title, 243 data_size_widget=data_size_widget, 244 show_warnings=warnings, 245 layout_array=layout_array, 246 )
File ~/miniconda3/envs/rapids-23.10/lib/python3.10/site-packages/cuxfilter/dashboard.py:186, in DashBoard.init(self, charts, sidebar, dataframe, layout, theme, title, data_size_widget, show_warnings, layout_array) 184 for chart in sidebar: 185 if chart.is_widget: --> 186 chart.initiate_chart(self) 187 chart._initialized = True 188 self._sidebar[chart.name] = chart
File ~/miniconda3/envs/rapids-23.10/lib/python3.10/site-packages/cuxfilter/charts/panel_widgets/plots.py:334, in MultiChoice.initiate_chart(self, dashboard_cls) 328 self.min_value, self.max_value = get_min_max( 329 dashboard_cls._cuxfilter_df.data, self.x 330 ) 331 self.source = dashboard_cls._cuxfilter_df.data[self.x].reset_index( 332 drop=True 333 ) --> 334 self.calc_list_of_values(dashboard_cls._cuxfilter_df.data) 335 self.generate_widget() 336 self.add_events(dashboard_cls)
File ~/miniconda3/envs/rapids-23.10/lib/python3.10/site-packages/cuxfilter/charts/panel_widgets/plots.py:347, in MultiChoice.calc_list_of_values(self, data) 344 if isinstance(data, dask_cudf.core.DataFrame): 345 self.list_of_values = self.list_of_values.compute() --> 347 self.list_of_values = self.list_of_values.to_pandas().tolist() 349 if len(self.list_of_values) > 500: 350 print( 351 """It is not recommended to use a column with 352 so many different values for MultiChoice menu""" 353 )
AttributeError: 'ndarray' object has no attribute 'to_pandas'
chart3 = cuxfilter.charts.range_slider('RSRP_Status') --> working chart3 = cuxfilter.charts.drop_down('RSRP_Status') --> not working
Herewith the dtypes Tile Id int64 Date datetime64[ns] Serving Cell Average RSRP (All) (dBm) float64 Serving Cell Average RSRQ (All) (dB) float64 Total MR Count int64 Longitude float64 Latitude float64 x float64 y float64 RSRP_Status int64 dtype: object