jupyter-widgets / ipydatagrid

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

ipydatagrid is slow compared to ipyaggrid #286

Closed mhouston2 closed 2 years ago

mhouston2 commented 2 years ago

I have been a user of ipyaggrid for a bit and I like it a lot. Recently it started breaking when using newer versions of jupyter lab so I've looked into trying out ipydatagrid. However, ipydatagrid is running very slowly. I have a 6x52 sized dataframe with nothing fancy just text/numbers that is embedded within HBox and VBox widgets. There is almost a 1 second lag when I click a cell and it gets selected. This is all I have:

grid = DataGrid(df, layout={"height": '600px'}, selection_mode="cell") grid.auto_fit_columns = True grid.auto_fit_params = {"area": "body", "padding": 60}

Any thoughts?

ibdafna commented 2 years ago

Hi @mhouston2 and welcome to the ipydatagrid community!

Can you please share a full reproducible snippet including your pandas dataframe and the browser you're using?

Many thanks

mhouston2 commented 2 years ago

Hi. I have a little more information. When preparing the reproducible snippet into a separate notebook for you I noticed it runs much faster in a new clean notebook. The notebook I had been running the code in previously had about 870 cells of code (I cleared all the output though so it's only regular code that remains.). I am running Firefox 95.0 on Linux. Would you still like to see the snippet? I haven't had this problem with grids before in the large notebook although it does take time to load the notebook initially.

martinRenou commented 2 years ago

Is this using JupyterLab or Jupyter Notebook?

The notebook I had been running the code in previously had about 870 cells of code

That seems like a lot of cells IMO. Splitting your Notebook into multiple Notebooks and Python files might help on this.

If you are using JupyterLab, there are some performance improvements concerning the Notebook rendering that should come soon. This might improve the use case of ~1000 cells Notebook.

ibdafna commented 2 years ago

Closing this but feel free to reopen if anything comes up!

ankostis commented 1 year ago

Please reopen, for 200.000x3 cells, it takes x3 (9.5sec vs 3.0sec) more than ipyaggrid:

>>> import pandas as pd
>>> import numpy as np
>>> import jupyter
>>> jupyter.__version__
'1.0.0'

>>> df=pd.DataFrame(np.random.rand(200_000,3), columns=list("ABC"))

>>> import ipydatagrid
>>> ipydatagrid.__version__
'1.1.15'

>>> %time dg = ipydatagrid.DataGrid(df)
CPU times: user 9.36 s, sys: 119 ms, total: 9.48 s
Wall time: 9.48 s
>>> %time display(dg)
CPU times: user 0 ns, sys: 3.04 ms, total: 3.04 ms
Wall time: 1.86 ms

>>> import ipyaggrid
>>> ipyaggrid.__version__
'0.3.2'

>>> dd, grid_options = ipyaggrid.util.Util.prepare_singleindex_df(df, {})
>>> %time ag = ipyaggrid.Grid(grid_data=df grid_options=grid_options)
CPU times: user 2.59 s, sys: 40 ms, total: 2.63 s
Wall time: 2.63 s
>>> %time display(ag)
CPU times: user 0 ns, sys: 2.08 ms, total: 2.08 ms
Wall time: 1.73 ms
ankostis commented 1 year ago

With more columns, 200,000 x 30, it takes x2 more (60sec vs 35sec).