mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
age band calculator
This commit is contained in:
parent
f9633618b1
commit
d2cc39a565
1 changed files with 18 additions and 3 deletions
|
|
@ -53,7 +53,22 @@ for installer in installers:
|
|||
df["week_commencing"] = date
|
||||
all_dfs.append(df)
|
||||
|
||||
giant_df = pd.concat(all_dfs, ignore_index=True)
|
||||
giant_df
|
||||
giant_df.to_csv("age_band.csv")
|
||||
for df in all_dfs:
|
||||
print(df)
|
||||
|
||||
|
||||
giant_df = pd.concat(all_dfs, ignore_index=True)
|
||||
giant_df.to_excel("age_band.xlsx", index=False)
|
||||
|
||||
giant_df['week_commencing_cleaned'] = pd.to_datetime(
|
||||
giant_df['week_commencing'].str.replace("W.C. ", ""),
|
||||
dayfirst=True
|
||||
)
|
||||
pd.set_option('display.max_rows', None)
|
||||
|
||||
grouped = giant_df.groupby(['week_commencing_cleaned', 'age_band']).size().unstack(fill_value=0)
|
||||
grouped = grouped.sort_index()
|
||||
print(grouped)
|
||||
|
||||
output_file = "grouped_age_band_by_week.xlsx"
|
||||
grouped.to_excel(output_file)
|
||||
Loading…
Add table
Reference in a new issue