DataFrame and Plots 🎲📊

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import mercury as mr
# control app with App class
app = mr.App(title="DataFrame & Plots 🚀", description="Showcase of Mercury Widgets", show_code = False)

Share your notebooks with everyone thanks to Mercury framework.

Please change number of samples and number of features in the left side bar. Notebook will be recomputed after widget change.

samples = mr.Slider(label="Number of samples", min=50, max=100, value=75)
features = mr.Select(label="Number of features", choices=["5", "10", "15"], value="10")
data = {}
for i in range(int(features.value)):
    data[f"Feature {i}"] = np.random.rand(samples.value)
df = pd.DataFrame(data)

Random data 🎲

df

Scatter plot 📈

_ = plt.plot(df["Feature 1"], df["Feature 2"], '*')

Random data histogram 📊

_ = plt.hist(df["Feature 1"], bins=40)