Oct-31-2017, 02:57 PM
Hi guys
I'm trying to figure out how to replace a string in dataframe using regex's match
In my case I want to get rid of parenthesis and what is inside it
Example: What I have
Name
1 John
2 Lucy Smart
3 Nick (Sweet)
What I expect to get
Name
1 John
2 Lucy Smart
3 Nick
I need something like:
users['Name'].replace(to_replace=r"(?P<f_name>\w+)(?P<l_name>\w+)(?P<par>\(\w+\))", value='<f_name> <l_name>', inplace=True, regex=True)
But I can't figure out how to connect between a value field and to_replace
Anyone can help?
Thanks
Naama
I'm trying to figure out how to replace a string in dataframe using regex's match
In my case I want to get rid of parenthesis and what is inside it
Example: What I have
Name
1 John
2 Lucy Smart
3 Nick (Sweet)
What I expect to get
Name
1 John
2 Lucy Smart
3 Nick
I need something like:
users['Name'].replace(to_replace=r"(?P<f_name>\w+)(?P<l_name>\w+)(?P<par>\(\w+\))", value='<f_name> <l_name>', inplace=True, regex=True)
But I can't figure out how to connect between a value field and to_replace
Anyone can help?
Thanks
Naama