Hello I can’t seem to get a dataframe table rendered using hvplot.table() or pn.panel.DataFrame or pn.widgets.DataFrame when using an on_click() event. Outside of an on_click() event, I can get a dataframe to render fine.
panel==0.12.6
bokeh==2.4.2
hvplot==0.7.3
jupyterlab==3.2.3
With the code below, nothing gets rendered when I click on the button.
import pandas as pd
import panel as pn
import hvplot.pandas
button = pn.widgets.Button(name='Click Me', button_type='primary')
def my_func(event=None):
df = pd.read_csv('https://raw.githubusercontent.com/rashida048/Datasets/master/cars.csv')
print(df.head())
return df.hvplot.table()
button.on_click(my_func)
pn.Column(button)
Printing the df works so I know I have a known good dataframe.
However, if I make my_func() a “standalone” function or not with on_click() event, the dataframe gets rendered fine:
import pandas as pd
import panel as pn
import hvplot.pandas
def my_func():
df = pd.read_csv('https://raw.githubusercontent.com/rashida048/Datasets/master/cars.csv')
return df.hvplot.table()
my_func()
I ran pn.extension()
also, but still the same no good result. I have jupyterlab version 3.2.3.
Any help with this is much appreciated!
Daniel