jupyter-widgets / ipydatagrid

Fast Datagrid widget for the Jupyter Notebook and JupyterLab
BSD 3-Clause "New" or "Revised" License
580 stars 51 forks source link

How to create a sortable and filterable Datagrid #466

Closed f3rn4nd0-c354r closed 10 months ago

f3rn4nd0-c354r commented 11 months ago

Hello,

I'm having a lot of troubles making this work. I can create a datagrid, but not sort it or filter it.

What ma I doing wrong?

import pandas as pd
from ipydatagrid import DataGrid

# Sample dictionary with words and frequencies
word_freq_dict = {'apple': 5, 'orange': 8, 'banana': 3, 'grape': 6}

# Convert the dictionary to a DataFrame
df = pd.DataFrame(word_freq_dict.items(), columns=['Word', 'Frequency'])

# Sort the DataFrame by the 'Frequency' column in descending order
df = df.sort_values(by='Frequency', ascending=False)

# Display the sorted DataFrame
dg = DataGrid(df)
dg

This creates a DataGrib, but one that is not sortable, and has no filters.

image

Version: Jupyter Labs Version 4.0.9

afonit commented 10 months ago

When you click on the little funnels next to the column names - what happens?

Using your code, here is what happens for me: example_0011

f3rn4nd0-c354r commented 10 months ago

Nothing happens. The icon seems to be greyed out. Is there some "browser log" I can check if there's some error?

martinRenou commented 10 months ago

This is a duplicate of https://github.com/bloomberg/ipydatagrid/issues/446.

You need to either downgrade ipydatagrid or wait for 1.2.1 to be out. Sorry for the inconvenience.