quantopian / qgrid

An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks
Apache License 2.0
3.05k stars 421 forks source link

AttributeError: 'DataFrame' object has no attribute 'map' #370

Open kevalshah90 opened 2 years ago

kevalshah90 commented 2 years ago

Environment

Description of Issue

Issue rendering the dataframe. Exception: AttributeError: 'DataFrame' object has no attribute 'map'

Render dataframe

/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/qgrid/grid.py in show_grid(data_frame, show_toolbar, precision, grid_options, column_options, column_definitions, row_edit_callback)
    504 
    505     # create a visualization for the dataframe
--> 506     return QgridWidget(df=data_frame, precision=precision,
    507                        grid_options=grid_options,
    508                        column_options=column_options,

/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/qgrid/grid.py in __init__(self, *args, **kwargs)
    625 
    626         if self.df is not None:
--> 627             self._update_df()
    628 
    629     def _grid_options_default(self):

/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/qgrid/grid.py in _update_df(self)
    818         self._unfiltered_df = self._df.copy()
    819 
--> 820         self._update_table(update_columns=True, fire_data_change_event=False)
    821         self._ignore_df_changed = False
    822 

/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/qgrid/grid.py in _update_table(self, update_columns, triggered_by, scroll_to_row, fire_data_change_event)
    909                 series_to_set = df[sort_column_name]
    910             else:
--> 911                 series_to_set = self._get_col_series_from_df(
    912                     col_name, df, level_vals=True
    913                 ).map(stringify)

/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5485         ):
   5486             return self[name]
-> 5487         return object.__getattribute__(self, name)
   5488 
   5489     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'map'

Reproduction Steps -

It happens in my environment with this particular DataFrame. Other DataFrames are rendered fine, no issue with them.

  1. Unable to share the entire DataFrame. However, I have confirmed that the object is of type: pandas.core.frame.DataFrame

...

What steps have you taken to resolve this already?

...

Anything else?

...