0

I am trying to create a dictionary and I want to flush data from the dataframe cluster_set at the start of each iteration. I am using the following code.

Please let me know if more input is required from my end as I am new to this platform and python as well.....:D So, so I am not sure how much info is required.

for x in uni_cluster:
     cluster_boo = pd.Series([] , dtype = bool)
     cluster_boo = pdf_copy['Clus_Db'] == x
     cluster_set = pdf_copy[cluster_boo]
     cluster_dic = {x: cluster_set for x in uni_cluster}
Honey Ali
  • 1
  • 1
  • Your question is not really clear. Please add a [MRE](https://stackoverflow.com/help/minimal-reproducible-example) (also look [here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)) that replicates your problem. Looks like you want: `cluster_dic = {x: cluster for x, cluster in pdf_copy.groupby('Clus_Db') if x in uni_cluster}` (without the outer loop)? – Timus Sep 23 '22 at 10:56

0 Answers0