I have a field that has 3 different values in any order I need to separate data into its own column not sure how to do this. In SQL Server, I would use charindex to find anchor location and extract what I need in Python I am not sure.
Here is a sample set:(all this data is in 1 column goal is to split it into its own column with just integer value)
3 bike, 4 cars, 2 mopeds
3 cars, 4 mopeds, 6 bike
1 mopeds, 2 bike, 3 cars
This is what I have so far
df['bike'] = df['transport'].apply(lambda row: row[row.index('bike')-2 : row.index('bike')-1])
I changed transport to type string since by default its an object.
I get this error
ValueError: substring not found
Could this be because there are some cells with no value?