import bia_bob
import seaborn as sns
import pandas as pd
# Load the penguin dataset
penguins_df = sns.load_dataset('penguins')
# Display the first few rows of the DataFrame
penguins_df.head()
species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | |
---|---|---|---|---|---|---|---|
0 | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male |
1 | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female |
2 | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female |
3 | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN |
4 | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female |
You can ask %bob
to visualize data for you. In case stackview
is installed and you mention a use-case for it, it may propose code like this:
%bob display the penguins_df in two connected scatterplots side-by-side.
I will create two connected scatterplots side-by-side using the penguins_df DataFrame, allowing for interactive selection between the plots.
import ipywidgets as widgets
from ipywidgets import HBox
import stackview
def update2(e=None):
widget2.update()
def update1(e=None):
widget1.update()
widget1 = stackview.scatterplot(df=penguins_df, column_x="bill_length_mm", column_y="bill_depth_mm", selection_changed_callback=update2)
widget2 = stackview.scatterplot(df=penguins_df, column_x="flipper_length_mm", column_y="body_mass_g", selection_changed_callback=update1)
display(HBox([widget1, widget2])) # Arrange the widgets side by side using HBox
HBox(children=(HBox(children=(VBox(children=(VBox(children=(HBox(children=(Label(value='Axes '), Dropdown(inde…