I have 2 questions:
I have a dataset that contains some duplicate IDs, but some of them have different actions so they can't be removed. I want for each ID to do some math and store the final value to work with later. I already have duplicate indices, but in this code, it doesn't work properly and gives NaN.
How can I write nested loop using pandas? Cause it takes too much time to run. I've already used iterrows(), but didn't work.
l_list = [] for i in range(len(idx)): for j in range(len(idx[i])): if df.at[j,'action'] == 0: a = df.rank[idx[i]]*50 b = df.study_list[idx[i]].str.strip('[]').str.split(',').str.len() l_list.append(a + b)