If I have a mapping like so:
mapping_dict = {
0.0: "I0",
2.0: "I1",
4.0: "I2",
6.0: "I3"
}
If I have this mapping, and I want to map it to a different column as I do here currently:
ila_df.loc[ila_df.injection_type == 0.0, "strategy"] = "I0"
what’s the best way to do this? I’ve used the mapping for the same columns but not entirely sure how to do this comparison for different columns?
CodePudding user response:
From the comments:
ila_df['strategy'] = ila_df.injection_type.map(mapping_dict)
is all you need to do.