I'm trying to find the starting position of a string in an URL contained in column['url'] if column ['Existe'] contains "F" or "D". I'm new to Python and I'm trying to replicate a workflow from Excel in Python and after an hour of trying methods with lambda, numpy.where or numpy.select, and searching the web, I had to ask for help.
I've tried applying the following code, but this only returns that the value exists, but doesn't actually gives me the position in the string. What I currently have is:
df['Start']= ["/t/" in x[0] and "F" in x[1] for x in zip(df['url'],df['Existe'])]
Basically, the results it gives me is the following:
order id date time URL typedCount transition Existe Start
0 0 14438 1/3/2021 14:49:37 messenger.com/t/xxxxx 0 link F True
1 1 14437 1/3/2021 14:49:18 messenger.com/t/xxxxx 0 link F True
What I'm trying to do is to find the starting position of "/t/" in df['url'] if "F" exists in df['Existe'] and placing the result in a new column, df['Start']. I have to use this conditional because df['Existe'] contains both "F" and "D", and it has to look for "/t/" if it's "F", and "/@me/" if it's "D".
The result I'm looking for is:
order id date time URL typedCount transition Existe Start
0 0 14438 1/3/2021 14:49:37 messenger.com/t/xxxxx 0 link F 14
1 1 14437 1/3/2021 14:49:18 messenger.com/t/xxxxx 0 link F 14
Does anyone know a way of doing this?
Thanks