Change multiple value in one column

HI! try to understand str.map() method here. after we changed the value in ‘os’ column, I printed the frequency of ‘os’ column. I still see Mac OS and mac OS, It seems that we did not save the change to laptops file after we mapped. What we need to do here?

https://app.dataquest.io/m/293/data-cleaning-basics/9/correcting-bad-values

mapping_dict = {
    'Android': 'Android',
    'Chrome OS': 'Chrome OS',
    'Linux': 'Linux',
    'Mac OS': 'macOS',
    'No OS': 'No OS',
    'Windows': 'Windows',
    'macOS': 'macOS'
}

laptops['os'].map(mapping_dict)
print(laptops['os'].value_counts())```
3 Likes

You are not assigning it back to the laptops variable.

laptops['os'] = laptops['os'].map(mapping_dict)

The map method is not executed in place.

3 Likes

This was helpful

But i still don’t understand this expression “s = s.map(corrections)”. what is the “s.” What “s” function?Is it a variable because i can’t see the value(s) in the note.

“s” is short for Series. laptops['os'] is a column from the laptops DataFrame, therefore it is a Series.

1 Like

Alright. Thanks for the response

1 Like