Skip to content

Instantly share code, notes, and snippets.

@ericgitonga
Last active June 24, 2021 06:37
Show Gist options
  • Save ericgitonga/86ee7f12fb75a421417ff0dc8aa1b508 to your computer and use it in GitHub Desktop.
Save ericgitonga/86ee7f12fb75a421417ff0dc8aa1b508 to your computer and use it in GitHub Desktop.
df["month"] = df.index.month_name()
high_month_list = []
for year in list(df["year"].unique()):
df_high_month = df[df["year"] == year][["year","funded_amount","month"]]
df_high_month = df_high_month.groupby(["year","month"])["funded_amount"].sum().sort_values(ascending=False).head(1)
high_month_list.append(df_high_month)
df_high_month = pd.concat(high_month_list).reset_index()
df_high_month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment