Read data in the browser

Read a bundled CSV file with Pandas and draw a Seaborn plot.

Choose Run in browser, then use Run > Run All Cells in JupyterLite. The bundle includes this notebook and its CSV file.

Read a local CSV file

The sample file holds invented measurements for two plants. Its path stays data/measurements.csv in the browser and in the download.

import pandas as pd

measurements = pd.read_csv("data/measurements.csv")
measurements
plant week height_cm
0 Basil 1 4
1 Basil 2 7
2 Basil 3 10
3 Basil 4 14
4 Mint 1 5
5 Mint 2 8
6 Mint 3 12
7 Mint 4 17

Draw the measurements

Seaborn draws one line for each plant. The first code cell in the browser copy installs the packages found in the imports.

import matplotlib.pyplot as plt
import seaborn as sns

fig, ax = plt.subplots(figsize=(7, 3.5))
sns.lineplot(data=measurements, x="week", y="height_cm", hue="plant", marker="o", ax=ax)
ax.set(xlabel="Week", ylabel="Height (cm)", title="Example plant measurements")
ax.set_xticks([1, 2, 3, 4])
fig.tight_layout()
plt.show()

Try a change

Change the plot to sns.scatterplot and remove marker="o". Run that cell again to draw separate points.