I am trying to clean data using fuzzy match. The df like:
category description
1 almnd
1 almond
2 choc
2 choco
I want to have all similar descriptions to be same one under same category like that:
category description
1 almnd
1 almnd
2 choc
2 choc
Convert your dataframe to a dictionary, and remap.
dico = dict(df.to_dict('split')['data'])
df['description'] = pd["category"].map(dico)
If your dataframe actually has more than these two columns check the accepted answer on dictionary extraction.
dataframe to dict such that one column is the key and the other is the value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With