Answers for "python replace col values by other df"

16

replace column values pandas

df['column'] = df['column'].str.replace(',','-')
df
Posted by: Guest on February-25-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

Python Answers by Framework

Browse Popular Code Answers by Language