Plot uploaded files

read_csv sample tables, then draw bars and scatter.

Download the sample files from the banner, then click Add files in the workbench. read_csv looks in /uploads.

Goal

List /uploads, load sales.csv and sales_log.csv, and draw a bar chart and a scatter.

See what is attached

import os

print("uploads:", os.listdir("/uploads"))

If that list is empty, attach the files and run again.

Sales bars

import os

print("uploads:", os.listdir("/uploads"))
df = pd.read_csv("sales.csv")
print(df)
sns.barplot(data=df, x="city", y="revenue", hue="product", errorbar=None)
plt.title("Revenue from sales.csv")
plt.show()

Both sales.csv and /uploads/sales.csv work.

Scatter from the log

log = pd.read_csv("sales_log.csv", parse_dates=["date"])
log["revenue"] = log["units"] * log["price"]
print(log.head())
sns.scatterplot(data=log, x="units", y="revenue", hue="city", style="product")
plt.title("sales_log.csv")
plt.show()

Join a lookup

log = pd.read_csv("sales_log.csv")
regions = pd.read_csv("regions.csv")
log = log.merge(regions, on="city")
log["revenue"] = log["units"] * log["price"]
sns.barplot(data=log, x="region", y="revenue", estimator="sum", errorbar=None)
plt.title("Revenue by region")
plt.show()
Pitfall

FileNotFoundError means the workbench cannot see the file in /uploads. Download from the banner, then Add files. Do not use sns.load_dataset — it tries to fetch GitHub.