'Problem with time performing code pandas in for loop
I have a problem with time performing code:
groupkk = finishdset.groupby(["w_usr.name", "prs_id"], as_index=False)["cnt"].count()
grcnt = groupkk.shape[0] # cont groups - 140000
for i2 in range(grcnt):
if groupkk["prs_id"].values[i2] != '':
subgroup = finishdset[finishdset["prs_id"] == groupkk["prs_id"].values[i2]][["type","w_usr.login"]].drop_duplicates("w_usr.login", keep='last')#.iloc[3] #Раскрыть всех учатников группы
if subgroup[subgroup["type"] == "phone"].shape[0] == 1:
groupkk["phone"].values[i2] = subgroup[subgroup["type"] == "phone"].values[0][1]
groupkk["tag"].values[i2] = "Ready"
I want to update frame 'groupkk' depends on the contents.
Are there a more elegant ways?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
