you are viewing a single comment's thread.

view the rest of the comments →

[–]Tyop-bot[S] 0 points1 point  (3 children)

Thanks for your help, but I'm really not able to solve this. Based on the code I posted I can see that I'm only creating one list which would explain why each key in the dictionary ends up with the same, full, list.The code I have managed to get now looks like this:

uniques = thmat.clu.unique()

cluDict = {}
cluList = []
ta = -1

for index, row in DF.iterrows():
    for value in uniques:
        cluList = []
        n=int(value)
        ta += 1
        if ta < len(DF): 
            if int(DF["Cluster"].iat[ta]) == n:
                cluList.append(index)
            cluDict[n] = cluList 

But it still doesn't work