-
-
Notifications
You must be signed in to change notification settings - Fork 569
Open
Description
panel==1.5.3
I would like to add support for Polars DataFrame to GraphicWalker.object. Its unclear to me whether this is supported and how. I guess special care is taken about pandas dataframe serialization? Please support it.
import panel as pn
import param
from panel.custom import JSComponent
import polars as pl
import pandas as pd
pn.extension()
class GraphicWalker(JSComponent):
object = param.ClassSelector(class_=(pd.DataFrame, pl.DataFrame))
_esm = '''
export function render({ model, el }) {
console.log(model.object)
el.innerHTML = `<h1>Hello World</h1>`
}
'''
GraphicWalker(object=pl.DataFrame({"x": [1,2,3]})).servable()TypeError: the truth value of a DataFrame is ambiguous
Hint: to check if a DataFrame contains any values, use is_empty().
Traceback (most recent call last):
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/panel/io/handlers.py", line 405, in run
exec(self._code, module.__dict__)
File "/home/jovyan/repos/private/panel-graphic-walker/script.py", line 20, in <module>
GraphicWalker(object=pl.DataFrame({"x": [1,2,3]})).servable()
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/panel/viewable.py", line 399, in servable
self.server_doc(title=title, location=location) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/panel/viewable.py", line 1006, in server_doc
model = self.get_root(doc)
^^^^^^^^^^^^^^^^^^
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/panel/viewable.py", line 678, in get_root
root = self._get_model(doc, comm=comm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/panel/custom.py", line 436, in _get_model
model = self._bokeh_model(**self._get_properties(doc))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/panel/custom.py", line 390, in _get_properties
'data': self._data_model(**{p: v for p, v in data_props.items() if p not in ignored}),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/bokeh/model/data_model.py", line 49, in __init__
super().__init__(*args, **kwargs)
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/bokeh/model/model.py", line 119, in __init__
super().__init__(**kwargs)
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/bokeh/core/has_props.py", line 304, in __init__
setattr(self, name, value)
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/bokeh/core/has_props.py", line 336, in __setattr__
return super().__setattr__(name, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/bokeh/core/property/descriptors.py", line 332, in __set__
self._set(obj, old, value, setter=setter)
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/bokeh/core/property/descriptors.py", line 598, in _set
if self.property.matches(value, old) and (hint is None):
File "/home/jovyan/repos/private/panel-graphic-walker/.venv/lib/python3.11/site-packages/polars/dataframe/frame.py", line 1114, in __bool__
raise TypeError(msg)
TypeError: the truth value of a DataFrame is ambiguous
Hint: to check if a DataFrame contains any values, use `is_empty()`.Metadata
Metadata
Assignees
Labels
No labels