Reputation: 2273
I have the following df:
concatenar buy_sell
1 BBVA2018-03-2020 sell
5 santander2018-03-2020 buy
I would like to apply regex to the concatenar
column, where I would like to display the [A-Z][a-z]
inside that column
values.
This is what I have tried:
re.findall(r'[A-Z][a-z]*',df['concatenar'])
But outputs:
TypeError: expected string or bytes-like object
My desired output would be :
concatenar buy_sell
1 BBVA sell
5 santander buy
How could I correctly apply the regex
to the concatenar
column?
Upvotes: 0
Views: 1807
Reputation: 323396
replace
with dict
df.concatenar.replace({r'\d+':'','-':''},regex=True)
Out[354]:
1 BBVA
5 santander
Name: concatenar, dtype: object
Upvotes: 1