Skip to content

Instantly share code, notes, and snippets.

@chrisdmell
Created January 15, 2022 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdmell/1be780817cdc1f777153a408fef48791 to your computer and use it in GitHub Desktop.
Save chrisdmell/1be780817cdc1f777153a408fef48791 to your computer and use it in GitHub Desktop.
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