Inspired by the tweet https://twitter.com/driscollis/status/1511029437910945810?s=20&t=Sv-BJNl3eaAKZIFyu8oM7Q I created the below example
I think hvplot
.interactive
is really, really powerful, but I don’t see a lot using it yet. How would you use it?
import hvplot.pandas # adds .hvplot and .interactive to DataFrames
import numpy as np
import pandas as pd
import panel as pn
pn.extension(sizing_mode="stretch_width")
df = pd.read_json("https://api.github.com/users/marcskovmadsen/repos?perpage=100")
pn.panel(
"# Make your Dataframe analysis interactive with hvplot .interactive",
background="black",
style={"color": "white", "padding": "25px"},
).servable()
columns = ["name", "stargazers_count", "forks"]
sort_value = pn.widgets.Select(value="stargazers_count", options=columns, name="Sort by")
ascending = pn.widgets.Checkbox(value=False, name="Sort ascending")
rows = pn.widgets.IntSlider(value=10, start=1, end=20, step=1, name="Rows")
# df_interactive also works in your notebook
df_interactive = df.interactive[columns].sort_values(sort_value, ascending=ascending).head(rows)
pn.panel(df_interactive).servable()