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

DataGrid to Pandas DataFrame #549

Closed Castelloz closed 1 month ago

Castelloz commented 1 month ago

Hello,

I have not found a way to transform the data from DataGrid to Python DataFrame.

Would appreciate if someone could share any solution for this.

Thanks

martinRenou commented 1 month ago

Isn't simply datagrid.data what you need?

Castelloz commented 1 month ago

Thank you for your quick reply.

I have a Pandas DataFrame and then use ipydatagrid to edit my data. When finished editing my data I would then like to Pandas DataFrametransform it back to a df.

Is there a solution for this?

martinRenou commented 1 month ago

Then what I just suggested works :)

Please look at this example: https://github.com/jupyter-widgets/ipydatagrid/blob/main/examples/CellEditing.ipynb

You'll see that datagrid.data provides the dataframe updated after edits

Castelloz commented 1 month ago

Thank you. I will have a look at it.

Castelloz commented 1 month ago

Thank you @martinRenou

Your line of code worked like a charm :)

Feel bad that I didn`t get it when I was looking at this example initially some weeks ago. Haha