I trying to map a column in a new DF to values from different dictionaries. I have 2 simple Dicts one for all hostnames and for all all serial numbers. The key is the name or serial and the value is an int for ID. I want to fill in the "ID" column with wherever a match is found.
df["id"] = df["ALIAS_NAME"].str.lower().map(all_hostnames)
df["id"] = df["ASSET_NAME"].str.lower().map(all_hostnames)
df["id"] = df["SERIAL"].map(all_serials)
When I run the code above, it seems like only the last map is working and it overwrites the previous map commands. If no match is found in serials the previous value from the "id" column is replaced with NaN.
Is there a way to map only when the key is found in the dict?