Column name = "Insurance Type"
3 types of names in the columns "wa, wa_bep_ca" and "wa_ca".
Trying to replace these names with proper names. Any idea on why they don't get all replaced in the column?? Thanks for your support.
Column name = "Insurance Type"
3 types of names in the columns "wa, wa_bep_ca" and "wa_ca".
Trying to replace these names with proper names. Any idea on why they don't get all replaced in the column?? Thanks for your support.
Use replace on the column of interest, with a dictionary specifying:
The code to do it is:
df['Insurance type'].replace({
'wa_bep_ca': 'Liability + lim casco',
'wa_ca': 'Liability + full casco',
'wa': 'Liability only' }, inplace=True)
For the test I used the following DataFrame:
offer_number Insurance type
0 1001 wa
1 1002 wa_bep_ca
2 1003 wa_ca
3 1004 wa_xx
The result is:
offer_number Insurance type
0 1001 Liability only
1 1002 Liability + lim casco
2 1003 Liability + full casco
3 1004 wa_xx
(the last row does not match any of keys used, so it has not been replaced).