Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
groups = final_cleaned_df.groupby(["Bus","Service_Date_new"]).RecordedAt_new
min_val = groups.transform(min)
one_df = final_cleaned_df[(final_cleaned_df.RecordedAt_new==min_val) ]
one_df["date_diff"] = one_df.Service_Date_new - one_df.RecordedAt_new
figure(figsize=(10, 6), dpi=80)
plt.subplot(1, 2, 1)
plt.title("Date Difference Boxplot")
plt.boxplot(one_df.date_diff.astype('timedelta64[D]'))
plt.subplot(1, 2, 2)
plt.title("Date Difference Histogram")
plt.hist(one_df.date_diff.astype('timedelta64[D]'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment