Answers for "replace values in a column with another value pandas using dictionary"

4

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
Posted by: Guest on September-22-2021
0

pandas replace values from another dataframe

In [36]:
df['Group'] = df['Group'].map(df1.set_index('Group')['Hotel'])
df

Out[36]:
         Date  Group  Family  Bonus
0  2011-06-09  Jamel  Laavin    456
1  2011-07-09  Frank  Grendy    679
2  2011-09-10   Luxy  Fantol    431
3  2011-11-02  Frank  Gondow    569
Posted by: Guest on May-14-2021

Code answers related to "replace values in a column with another value pandas using dictionary"

Python Answers by Framework

Browse Popular Code Answers by Language