Hvplot.explorer(df) not working

Hi,
I’ve tried using the hvplot.explorer() function without any luck.
I’ve copy-pasted the code from the panel website (link
Code:

import io
import panel as pn
import pandas as pd
import hvplot.pandas

pn.extension(template='fast')

pn.state.template.title = 'hvPlot Explorer'
upload = pn.widgets.FileInput(name='Upload file', height=50)
select = pn.widgets.Select(options={
    'Penguins': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv',
    'Diamonds': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/diamonds.csv',
    'Titanic': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv',
    'MPG': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/mpg.csv'
})

def add_data(event):
    b = io.BytesIO()
    upload.save(b)
    b.seek(0)
    name = '.'.join(upload.filename.split('.')[:-1])
    select.options[name] = b
    select.param.trigger('options')
    select.value = b
    
upload.param.watch(add_data, 'filename')

def explore(csv):
    df = pd.read_csv(csv)
    explorer = hvplot.explorer(df)
    def plot_code(**kwargs):
        code = f'```python\n{explorer.plot_code()}\n```'
        return pn.pane.Markdown(code, sizing_mode='stretch_width')
    return pn.Column(
        explorer,
        '**Code**:',
        pn.bind(plot_code, **explorer.param.objects())
    )

widgets = pn.Column(
    "Select an existing dataset or upload one of your own CSV files and start exploring your data.",
    pn.Row(
        select,
        upload,
    )
).servable()  

output = pn.panel(pn.bind(explore, select)).servable()

pn.Column(widgets, output)

But I get the error message: <AttributeError: module ‘hvplot’ has no attribute ‘explorer’>

If I use hvplot.ui.hvPlotExplorer(df) I can create the explorer in general, but if I insert this into the example it now fails due to: <AttributeError: ‘hvDataFrameExplorer’ object has no attribute ‘plot_code’>

Is the example simply outdated? Or am I doing something wrong?

Best,
Jesper

I had a similar issue after installing Panel. Had to go and re-install Holoviews and HvPlot afterwards. Don’t know if it will solve your problem, but it’s worth a shot.

2 Likes

Hi @Jelle,

Just ran the code pasted in relatively new hvplot setup from few days ago, just to let you know I reviece no such errors in running, I think @riziles suggestion will get you going again.

Thanks, Carl.

1 Like

hvplot.explorer was made available starting from hvPlot 0.8.1, make sure you have this version or a more recent one.

hvplot.ui.hvPlotExplorer isn’t meant to be used directly :slight_smile:

3 Likes