I have panda data frame df:
Product_Code Date Price
A Jan 10.5
A Dec 11.2
B jun 8.1
...
Then there is dictionary which map every product_code to a unique product_Id like {(A:1},(B:2),...}. I want to apply this map to the df and convert product_code to product_Id:
df_new=df.replace({"Product_Code": mapp})
However it is very slow and take a lot of time for this conversion. Is there a better and efficient way to do it?
Thanks,
df.Product_Code = df.Product_Code.map(mapp)df['Product_Code'].replace(mapp)