-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolar_helper.py
29 lines (26 loc) · 961 Bytes
/
polar_helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""helper function for polar chart"""
import pandas as pd
def prepare_data_for_polar(complete_df, CATEGORY, CAT_SORTERS, station):
"""creates dataframes for median and max values for polar chart"""
df_median = (
complete_df[(complete_df.description == station)]
.groupby([CATEGORY, CAT_SORTERS[CATEGORY]])[["total_bikes"]]
.median()
.reset_index()
.sort_values(CAT_SORTERS[CATEGORY])
)
df_median["location"] = station
df_max = (
complete_df[(complete_df.description == station)]
.groupby([CATEGORY, CAT_SORTERS[CATEGORY]])[["total_bikes"]]
.max()
.reset_index()
.sort_values(CAT_SORTERS[CATEGORY])
)
df_max["location"] = station
radialrange_dict = {
"max": df_max["total_bikes"].max(),
"median": df_median["total_bikes"].max(),
}
categories = df_median[CATEGORY]
return df_median, df_max, radialrange_dict, categories