Given String;- "\NA*(0.0001,0.,NA,0.99999983,0.02) \EVENT=_Schedule185 \WGT=_WEEKS"
Output = EVENT=_Schedule185
CodePudding user response:
You can use string extract
df['col'].str.extract('(EVENT=_\S*) ')
CodePudding user response:
If you are able to get that into a dataframe then you can use this
df = pd.DataFrame({
'Column1' : [r"\NA*(0.0001,0.,NA,0.99999983,0.02) \EVENT=_Schedule185 \WGT=_WEEKS"]
})
df['Column1'].apply(lambda x : x.split('\\')[2])
However, you are doing all this on an escape character so it might be a little tricky depending on how your actual data is structured. This code, however, will produce the desired results.