Just wondering what I am doing wrong with regex(very new to it).
df
tradingsymbol
0 USDEUR18D21P
1 KNIFY20DEC182700P
I am trying to extract all characters before the first digit. And extract the part before it into another column.
I have tried:
df['tradingsymbol'].str.extract('^(\D)\d', expand=True)
It gives me all NaN
result.
I have tried a few other expressions and all have either returned NaN
or given an error about unbalance parenthesis.
How do I go about this?
Thanks in advance.
Expected o/p
df
tradingsymbol symbol
0 USDEUR18D21P USDEUR
1 KNIFY20DEC182700P KNIFY