Last active
June 24, 2021 06:35
-
-
Save ericgitonga/9cf50fdeb92d077257e0770b6eaaf5a9 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
df["days_in_month"] = df.index.daysinmonth | |
df_average = df.groupby(["year","month","month_number","days_in_month"])["funded_amount"].sum().reset_index() | |
df_average["monthly_average"] = round(df_average["funded_amount"] / df_average["days_in_month"],2) | |
sorted_df_average = [] | |
for year in list(df_average["year"].unique()): | |
sorted_df_average.append(df_average[df_average["year"] == year].sort_values(by="month_number")) | |
df_average = pd.concat(sorted_df_average).reset_index(drop=True).\ | |
drop(["month_number","days_in_month","funded_amount"],"columns") | |
df_average |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment