Answers for "how to change value in pandas dataframe"

12

replacing values in pandas dataframe

df['coloum'] = df['coloum'].replace(['value_1','valu_2'],'new_value')
Posted by: Guest on May-11-2020
3

replace multiple values in pandas column

df = pd.DataFrame({'a':['Small', 'Medium', 'High']})

In [22]: df
Out[22]: 
        a
0   Small
1  Medium
2    High

[3 rows x 1 columns]

df.replace({'a' : { 'Medium' : 2, 'Small' : 1, 'High' : 3 }})
Posted by: Guest on October-05-2020
0

dataframe change column value

df["column1"].replace({"a": "x", "b": "y"}, inplace=True)
Posted by: Guest on July-05-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

column.replace

df.column = df.coloumn.replace('old_value', 'new_value')
Posted by: Guest on January-26-2021

Code answers related to "how to change value in pandas dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language