I have a DataFrame named df as
Order Number Status
1 1668 Undelivered
2 19771 Undelivered
3 100032108 Undelivered
4
Expanding on the previous answers:
d dictionary, replacing any found keys with values from d.d will be set as NaN. This can be corrected with fillna() methods.pd.Series here.d = {'Delivered': True, 'Undelivered': False}
df["Status"].map(d)
d dictionary, and attempt to replace any found keys with values from d.d will be be retained.pd.Series or pd.DataFrame objects).d = {'Delivered': True, 'Undelivered': False}
df["Status"].replace(d)
Overall, the replace method is more robust and allows finer control over how data is mapped + how to handle missing or nan values.