Skip to content

Instantly share code, notes, and snippets.

@chrisdmell
Last active January 15, 2022 14:37
Show Gist options
  • Save chrisdmell/7456f15f1a90b801c3de1e790dc75dd7 to your computer and use it in GitHub Desktop.
Save chrisdmell/7456f15f1a90b801c3de1e790dc75dd7 to your computer and use it in GitHub Desktop.
one_df_002 = pd.merge(one_df,final_cleaned_df[["Bus","Service_Date","RecordedAt", "average_price_s1_s2_filled"]], how = "left" , left_on = ["Bus","Service_Date","min"], right_on =["Bus","Service_Date","RecordedAt"],
suffixes=('_left', '_right'))
one_df_003 = pd.merge(one_df_002,final_cleaned_df[["Bus","Service_Date","RecordedAt", "average_price_s1_s2_filled"]], how = "left" , left_on = ["Bus","Service_Date","max"], right_on =["Bus","Service_Date","RecordedAt"],
suffixes=('_left', '_right'))
one_df_003["price_diff_i_f"] = one_df_003.average_price_s1_s2_filled_right - one_df_003.average_price_s1_s2_filled_left
one_df_003["price_diff_i_f_perc"] = one_df_003.price_diff_i_f / one_df_003.average_price_s1_s2_filled_left
one_df_004 = one_df_003[["Bus","Service_Date", "price_diff_i_f"]].drop_duplicates()
one_df_005 = one_df_003[["Bus","Service_Date", "price_diff_i_f_perc"]].drop_duplicates()
one_df_005.boxplot(column = ["price_diff_i_f_perc"])
one_df_004.price_diff_i_f.hist(bins = 50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment