Skip to content

Tabulator.from_param fails as soon as the value is changed. #8538

Description

@dejfh

ALL software version info

Software Version Info
panel   1.8.10
pandas  3.0.1
param   2.3.2
bokeh   3.8.2
python  3.13.5
Ubuntu  24.04.3 LTS (in WSL)

Description of expected behavior and the observed behavior

When I create a Tabulator with Tabulator.from_param, updating the value fails with ValueError.

#8492 introduced a comparison between the current and the new value and expected to result to be a bool (see panel/param.py:575). In this case the values are DataFrames that do not return a bool but another DataFrame (type(pd.DataFrame() != pd.DataFrame()) == pd.DataFrame).

Complete, minimal, self-contained example code that reproduces the issue

import pandas as pd
import panel as pn
import param


class MyObject(param.Parameterized):
    data = param.DataFrame()


my_object = MyObject(data=pd.DataFrame({"a": [1, 2, 3]}))

tabulator = pn.widgets.Tabulator.from_param(my_object.param.data)

tabulator.value = pd.DataFrame({"a": [1, 2, 5]})

Stack traceback and/or browser JavaScript console output

Traceback (most recent call last):
  File "***/test.py", line 14, in <module>
    tabulator.value = pd.DataFrame({"a": [1, 2, 5]})
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "***/.venv/lib/python3.13/site-packages/param/parameterized.py", line 2970, in trigger
    self_.update(dict(params, **triggers))
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***/.venv/lib/python3.13/site-packages/param/parameterized.py", line 2788, in update
    restore = dict(self_._update(arg, **kwargs))
                   ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "***/.venv/lib/python3.13/site-packages/param/parameterized.py", line 2821, in _update
    self_._batch_call_watchers()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "***/.venv/lib/python3.13/site-packages/param/parameterized.py", line 3038, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "***/.venv/lib/python3.13/site-packages/param/parameterized.py", line 3000, in _execute_watcher
    watcher.fn(*args, **kwargs)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "***/.venv/lib/python3.13/site-packages/panel/param.py", line 575, in link_widget
    if not reset and current_val != new:
                     ^^^^^^^^^^^^^^^^^^
  File "***/.venv/lib/python3.13/site-packages/pandas/core/generic.py", line 1513, in __bool__
    raise ValueError(
    ...<2 lines>...
    )
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  • I may be interested in making a pull request to address this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions