Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

replace multiple column values pandas

import pandas as pd

df = pd.DataFrame([
	[4, -9, 8],
	[1, 2, -4],
    [2, 2, -8],
    [0, 7, -4],
	[2, 5, 1]],
	columns=['a', 'b', 'c'])

df = df.replace({'a':{1:11, 2:22}, 'b':{5:55, 2:22}})
print(df)
Source by pythonexamples.org #
 
PREVIOUS NEXT
Tagged: #replace #multiple #column #values #pandas
ADD COMMENT
Topic
Name
8+3 =