Load large dataset
We will load (quite) large dataset in this example. The data loading is done before adding Mercury Widgets. Thanks to this it will be executed only once. This greatly speedup the cells re-execution after widget update.
You will need
mercury packages to run this example.
In the first cell, please import required packages:
import pandas as pd import mercury as mr
Load dataset from remote resource, such loading might take a while:
df = pd.read_csv("https://raw.githubusercontent.com/pplonski/datasets-for-start/master/adult/data.csv")
Let's add a
Slider widget to control number of displayed samples:
samples = mr.Slider(value=10, label="Samples", min=1, max=20)
The screenshot of the notebook's code in the Jupyter Notebook:
Please start Mercury in the same directory as notebook:
You will see the app running at
http://127.0.0.1:8000. Below is an animation with Mercury App.
Mercury automatically executes cells after widget update. Only cell with widget definition and below are re-executed. Because of this re-execution strategy, cells above are not executed. The large dataset is loaded only once.