Skip to content Skip to sidebar Skip to footer

Replace Specific Values In A Dataframe Column Using Pandas

I have a data frame df with a column called 'Num_of_employees', which has values like 50-100, 200-500 etc. I see a problem with few values in my data. Wherever the employee number

Solution 1:

A clean syntax for this kind of "find and replace" uses a dict, as

df.Num_of_employees = df.Num_of_employees.replace({"10-Jan": "1-10",
                                                   "Nov-50": "11-50"})

Post a Comment for "Replace Specific Values In A Dataframe Column Using Pandas"