ipywidgets:
display
Usually code runs in your notebook because a cell is being run. What if instead it is triggered by a user interface element? It might be a better discovery tool or a better method for rapid prototyping. This is what the ipywidgets library tries to enable.
Notes
You can also make components that query text. Just make sure
you use display
when you're interested in showing dataframes.
import pandas as pd
import ipywidgets as widgets
df = pd.read_json("https://calmcode.io/datasets/pokemon.jsonl",
lines=True,
orient="record")
def reduce(q):
subset = df.loc[lambda d: d['name'].str.contains(q)]
display(subset)
q = widgets.Text()
out = widgets.interactive_output(reduce, {'q': q})
widgets.VBox([q, out])
Feedback? See an issue? Something unclear? Feel free to mention it here.
If you want to be kept up to date, consider signing up for the newsletter.