Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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 }})
 
PREVIOUS NEXT
Tagged: #replace #multiple #values #pandas #column
ADD COMMENT
Topic
Name
4+2 =