Feb-25-2022, 08:08 AM
(This post was last modified: Feb-25-2022, 08:08 AM by nicocorico.)
Hello everyone,
I am trying to isolate specific words out of a string if present but until now with no success.
If in the string I have 'irg', 'swopt', 'fvol' or 'swol' then I want to write the word found in a specific column. The string I look at have specific caracters.
Example: http:\dsddf;dfdfdf-dfdfd.irg/fdfdfd
I have tried the following code but with no success as it could found none of the word listed above and therefore as a result I have 'Category' column empty.
Would you see what might be wrong?
Thank you in advance for your help
,
Nicolas
I am trying to isolate specific words out of a string if present but until now with no success.
If in the string I have 'irg', 'swopt', 'fvol' or 'swol' then I want to write the word found in a specific column. The string I look at have specific caracters.
Example: http:\dsddf;dfdfdf-dfdfd.irg/fdfdfd
I have tried the following code but with no success as it could found none of the word listed above and therefore as a result I have 'Category' column empty.
category = r"irg|swopt|fvol|swvol" df_susanoo.insert(22, 'Category', df_susanoo['delivery_detail'].str.findall(category).apply(lambda x: x if len(x) >1 else ['not found']).str[-1])['delivery_detail'] column contains the string to look at.
Would you see what might be wrong?
Thank you in advance for your help

Nicolas