I am trying to map some data I get from another function to my Pandas dataframe. I create a simple dict for the lookup. For some reason the map function always creates float64 from integers.
So here I create a dictionary for the map function and force the ID to be an int.
all_serials = {phone["serial"]:int(phone["id"]) for phone in all_phones}
df["id"] = df["serial"].map(all_serials)
But still the "id" field is a float64 afterwards.
I have also tried to use astype function:
all_serials = {phone["serial"]:int(phone["id"]) for phone in all_phones}
df["id"] = df["serial"].map(all_serials).astype(int)
But then I get "Cannot convert non-finite values (NA or inf) to integer" for all the lines with no match(NaN as value).