I have a DateFrame with 'Break_Out_Category'
as a column. This column contains four variables ['Age Group', 'Race/Ethnicity', 'Gender', 'Overall']
. Now I am trying to create four different DataFrames for those different variables.
Ex:
df_by_age = df[df['Break_Out_Category'] == 'AGE Group']
Although, I don't want to hardcode and I am trying to write a loop for the same. Here is my code:
var_list = data_by_avg_days1['Break_Out_Category'].unique().tolist()
for var in var_list:
activity_limit_by_%var = data_by_avg_days1[data_by_avg_days1['Break_Out_Category'] == var]
print(activity_limit_by_%var['Break_Out_Category'].unique())
And this is the error I get
Error: activity_limit_by_%var = pd.DataFrame
^
SyntaxError: can't assign to operator
This is my first post here. So if I haven't posted the question in the right format. Do let me know, what I can do to ask in a better way.