Jun-12-2020, 09:00 AM
I have a dataframe with a little more than 15000 rows. I also have three lists (c_iddf, p_iddf, cr_iddf) that I converted from a .csv file, so all the lists have equal number of elements.
The dataframe df looks something like this
,
The dataframe df looks something like this
,
Login Caller ID Called number Call Start Call end Duration (s) block Effective Duration (s) blocks 0 6072132500 6072132500 0320585339 01/05/2020 16:25 01/05/2020 16:25 19 60 60 1.0 1 6072132500 6072132500 100 01/05/2020 21:04 01/05/2020 21:05 16 60 60 1.0 2 6072132500 6072132500 1300883000 01/05/2020 21:08 01/05/2020 21:08 9 60 60 1.0 3 6072132500 6072132500 15454 01/05/2020 21:13 01/05/2020 21:14 4 60 60 1.0 4 6072132500 6072132500 1300883000 01/05/2020 21:14 01/05/2020 21:14 16 60 60 1.0I want to check if the column 'Called number' has any values from p_iddf. If it has, then record the index of the element in the list p_iddf that matches the Called number value, and use that to get elements (with the same index number) from c_iddf and cr_iddf. I don't know if my logic is correct or not and would like suggestions on how I can do this some other way but if I add:
df['Check'] = df['Called number'].str.startswith(tuple(p_iddf))It does give me the correct boolean result (another column called Check with True and False)however I don't know how to get index numbers of p_iddf that matches with 'Called number' & the corresponding values from c_iddf and cr_iddf as per the index.