Skip to content

Instantly share code, notes, and snippets.

@ddfont
Created July 10, 2024 18:23
Show Gist options
  • Save ddfont/ae7163c981e9899ebd394d879751ccfc to your computer and use it in GitHub Desktop.
Save ddfont/ae7163c981e9899ebd394d879751ccfc to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("data.csv")
df.columns = [c.lower() for c in df.columns]
df = df[["period", "result", "starting_point_id", "online_hours", "undersupply_hours_pct", "oversupply_hours_pct",
"is_late20min", "nd", "num_delivs"]]
df = df.rename(columns={
"result": "group",
"starting_point_id": "spid",
"online_hours": "hours",
"undersupply_hours_pct": "uh",
"oversupply_hours_pct": "oh",
"is_late20min": "late",
})
df["late_count"] = df["late"] * df["num_delivs"]
df["nd_count"] = df["nd"] * df["num_delivs"]
df_exp = df[df.period == "experiment"]
g = sns.histplot(
data=df_exp[df_exp.uh < 0.8],
x="uh",
weights="num_delivs",
hue="group",
stat="probability",
common_norm=False,
bins=50,
)
g.set_yscale("log")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment