Changes via Tabulator are not persistent in underlying Dataframe

I am running jupyter lab via the latest official Jupyter docker “minimal-notebook” image, i.e “jupyter/minimal-notebook”. I have installed panel via “pip install panel”

Via the following code snippet I am trying to edit a Dataframe interactivel( by double clicking).

import panel as pn
import pandas as pd

pn.extension('tabulator')

df = pd.DataFrame([1,2,3])
pn.widgets.Tabulator(df)

However the edits are not visible within the underlying Dataframe, when i inspect the df variable afterwards.

I noted that outside the docker image, in a virtualenv (where I installed just jupyterlab and panel), it did work.

Any thoughts on how to troubleshoot / fix this?

I found the issue, it has nothing to do with docker, but something to do with the fact that I am using py:percent notebooks via Jupytext (see Notebooks as code — Jupytext documentation). I use this format for version control purposes.

These py:percent notebooks do not have an .ipynb extension, but a .py extension that are loaded via Jupytext, which I suspect might be related to the issue.

When I create a new notebook with an .ipynb I have no issue

I don’t think it should be persistent.

import panel as pn
import pandas as pd

pn.extension('tabulator')

df = pd.DataFrame([1,2,3])
table = pn.widgets.Tabulator(df)

After you make your edits, you can call table.value to get the latest perhaps?

table.value

I tried that but the value seems to always be the same as df

Oh, seems like a bug; can you file a GitHub issue on Panel?

Actually, I just tried it and it works:


import pandas as pd
import datetime as dt
df = pd.DataFrame({
    'int': [1, 2, 3],
    'float': [3.14, 6.28, 9.42],
    'str': ['A', 'B', 'C'],
    'bool': [True, False, True],
    'date': [dt.date(2019, 1, 1), dt.date(2020, 1, 1), dt.date(2020, 1, 10)],
    'datetime': [dt.datetime(2019, 1, 1, 10), dt.datetime(2020, 1, 1, 12), dt.datetime(2020, 1, 10, 13)]
}, index=[1, 2, 3])

df_widget = pn.widgets.Tabulator(df, buttons={'Print': "<i class='fa fa-print'></i>"})
df_widget.show()

Thanks for thinking along. So to clarify, I also got it to work in “Jupytext-less” context, i.e. by just using normal notebooks (with .ipynb extension). When doing the same thing in a py:percent notebook (via Jupytext) however, it does not seem to work. See the difference in action below:

2023-12-15 09.52.24

For context, I am using jupytext v1.16.0 (newest version) and this is the output of jupyter --version:

Selected Jupyter core packages...
IPython          : 8.16.1
ipykernel        : 6.25.2
ipywidgets       : 8.1.1
jupyter_client   : 8.4.0
jupyter_core     : 5.4.0
jupyter_server   : 2.8.0
jupyterlab       : 4.0.7
nbclient         : 0.8.0
nbconvert        : 7.9.2
nbformat         : 5.9.2
notebook         : 7.0.6
qtconsole        : not installed
traitlets        : 5.11.2

… and for lab extensions:

JupyterLab v4.0.7
/opt/conda/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled  X (python, jupyterlab_pygments)
        jupyterlab-plotly v5.18.0 enabled  X
        jupyterlab-jupytext v1.4.1 enabled OK (python, jupytext)
        nbdime-jupyterlab v2.2.0 enabled  X
        jupyter-matplotlib v0.11.3 enabled OK
        @jupyter-notebook/lab-extension v7.0.6 enabled OK
        @jupyterhub/jupyter-server-proxy v4.1.0 enabled OK
        @pyviz/jupyterlab_pyviz v3.0.0 enabled OK
        @jupyterlab/git v0.41.0 enabled  X (python, jupyterlab-git)
        @jupyter-widgets/jupyterlab-manager v5.0.9 enabled OK (python, jupyterlab_widgets)


   The following extensions are outdated:
        jupyterlab_pygments
        jupyterlab-plotly
        nbdime-jupyterlab
        @jupyterlab/git

   Consider checking if an update is available for these packages.

Other labextensions (built into JupyterLab)
   app dir: /opt/conda/share/jupyter/lab
        @plotly/dash-jupyterlab v0.4.3 enabled  X

   The following extensions are outdated:
        @plotly/dash-jupyterlab

   Consider checking if an update is available for these packages.

Update : I took the liberty to file an issue for this, see Changes via Tabulator are not persistent in underlying Dataframe in py:percent notebooks · Issue #6050 · holoviz/panel · GitHub