df['name'].str.replace(r"\(.*\)","")
You can’t run re functions directly on pandas objects. You have to loop them for each element inside the object. So Series.str.replace((r"\(.*\)", "")
is just syntactic sugar for Series.apply(lambda x: re.sub(r"\(.*\)", "", x))
.
More Related Contents:
- Fast punctuation removal with pandas
- Create Pandas DataFrame from txt file with specific pattern
- How to filter rows in pandas by regex
- re.sub erroring with “Expected string or bytes-like object”
- Strip / trim all strings of a dataframe
- pandas applying regex to replace values
- FutureWarning: The default value of regex will change from True to False in a future version
- applying regex to a pandas dataframe
- Python: UserWarning: This pattern has match groups. To actually get the groups, use str.extract
- How to use str.contains() with multiple expressions in pandas dataframes
- How to parse complex text files using Python?
- Get the row(s) which have the max value in groups using groupby
- Error: pandas hashtable keyerror
- How to filter rows containing a string pattern from a Pandas dataframe [duplicate]
- Python regex match OR operator
- Pandas Merge – How to avoid duplicating columns
- import text to pandas with multiple delimiters
- How to plot stacked event duration (Gantt Charts)
- Print very long string completely in pandas dataframe
- Remove duplicate chars using regex?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- How do I filter a pandas DataFrame based on value counts?
- Pandas query function not working with spaces in column names
- Remove NaN values from pandas dataframe and reshape table [duplicate]
- Python regex findall
- Changing certain values in multiple columns of a pandas DataFrame at once
- Round float columns in pandas dataframe
- Converting PANDAS dataframe from monthly to daily
- Pandas datetimes with different formats in the same column
- Get max value from row of a dataframe in python [duplicate]