Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas replace data in specific columns with specific values

### replace one value ###
df["column"].replace("US","UK") # you can also use numerical values
### replace more than one value ###
df["column"].replace(["man","woman","child"],[1,2,3]) # you can also use numerical values
#   man ==> 1
# woman ==> 2
# child ==> 3
Source by pandas.pydata.org #
 
PREVIOUS NEXT
Tagged: #pandas #replace #data #specific #columns #specific #values
ADD COMMENT
Topic
Name
9+3 =