Answers for "pandas replace string values in column"

6

find and replace string dataframe

df['range'] = df['range'].str.replace(',','-')
Posted by: Guest on March-29-2021
9

replace values of pandas column

df.loc[df['column'] == 'column_value', 'column'] = 'new_column_value'
Posted by: Guest on June-26-2020
0

pandas replace word begins with contains

df['sport'] = df.sport.str.replace(r'(^.*ball.*$)', 'ball sport')
df
Posted by: Guest on July-01-2020
0

pandas replace word begins with contains

df.sport = df.sport.apply(lambda x: 'ball sport' if 'ball' in x else x)
Posted by: Guest on July-01-2020

Code answers related to "pandas replace string values in column"

Python Answers by Framework

Browse Popular Code Answers by Language