We can output pandas tables either by printing them or using the HTML render and an Output
widget.
With illusionist
we make this static so it runs without a kernel.
import pandas as pd
import ipywidgets as w
df = pd.DataFrame(columns=["input", "operation", "squared", "as_str"])
s = w.IntSlider(min=1, max=3)
def update(value):
df.input = range(1, 10)
df.operation = df.input * value
df.squared = df.operation ** 2
df.as_str = df.operation.map(lambda x: str(x))
print(df)
out = w.interactive_output(update, {'value': s})
display(s, out)
s2 = w.IntSlider(min=1, max=3)
def update(value):
df.input = range(1, 10)
df.operation = df.input * value
df.squared = df.operation ** 2
df.as_str = df.operation.map(lambda x: "" if x == 0 else str(x))
display(df)
out2 = w.interactive_output(update, {'value': s2})
display(s2, out2)