Created
July 1, 2024 21:49
-
-
Save ddfont/cef3f9fef390efa82f01ac8870bbef7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
def plot_uh(): | |
g = sns.histplot( | |
data=df_exp, | |
x="uh", | |
weights="hours", | |
hue="group", | |
) | |
g.set_yscale("log") | |
plt.show() | |
def plot_uh_normalized(): | |
g = sns.histplot( | |
data=df_exp, | |
x="uh", | |
weights="hours", | |
hue="group", | |
stat="probability", | |
) | |
g.set_yscale("log") | |
plt.show() | |
def plot_late(): | |
g = sns.histplot( | |
data=df_exp, | |
x="uh", | |
weights="late_count", | |
) | |
g.set_yscale("log") | |
plt.show() | |
def plot_nd(): | |
g = sns.histplot( | |
data=df_exp, | |
x="uh", | |
weights="nd_count", | |
) | |
g.set_yscale("log") | |
plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment