here is what I am trying to do. I have one dataframe called df_prod_pivot_cluster
, with one column named 'cluster', with values ranging from 1 to 25.
I want to create 25 dataframes. I wrote the piece of code below, but how to do that in a more elegant way (for example: For x in range(1, 25):)?
ts_cluster1 = df_prod_pivot_cluster.loc[df_prod_pivot_cluster['cluster'] == 1]
ts_cluster1 = ts_cluster1.drop(columns='EASTING','NORTHING'])
ts_cluster1 = ts_cluster1.fillna(0)
ts_cluster1 = ts_cluster1.sum()
ts_cluster2 = df_prod_pivot_cluster.loc[df_prod_pivot_cluster['cluster'] == 2]
ts_cluster2 = ts_cluster2.drop(columns=['EASTING', 'NORTHING'])
ts_cluster2 = ts_cluster2.fillna(0)
ts_cluster2 = ts_cluster2.sum()
.
.
.
ts_cluster25 = df_prod_pivot_cluster.loc[df_prod_pivot_cluster['cluster'] == 25]
ts_cluster25 = ts_cluster25.drop(columns=['EASTING', 'NORTHING'])
ts_cluster25 = ts_cluster25.fillna(0)
ts_cluster25 = ts_cluster25.sum()