I have a python dataframe with a string column that I want to separate into several more columns.
Some rows of the DF look like this:
COLUMN
ORDP//NAME/iwantthispart/REMI/MORE TEXT
/REMI/SOMEMORETEXT
/ORDP//NAME/iwantthispart/ADDR/SOMEADRESS
/BENM//NAME/iwantthispart/REMI/SOMEMORETEXT
So basically i want everything after '/NAME/' and up to the next '/'. However. Not every row has the '/NAME/iwantthispart/' field, as can be seen in the second row.
I've tried using split functions, but ended up with the wrong results.
mt['COLUMN'].apply(lambda x: x.split('/NAME/')[-1])
This just gave me everything after the /NAME/ part, and in the cases that there was no /NAME/ it returned the full string to me.
Does anyone have some tips or solutions? Help is much appreciated! (the bullets are to make it more readable and are not actually in the data).