i am trying to find the item belongs to which category based on mode by using below pandas data frame
data
ITEM CATEGORY
1 red saree actual
2 red saree actual
3 glass lbh
4 glass lbh
5 red saree actual
6 red saree lbh
7 glass actual
8 bottle actual
9 bottle actual
what i am trying to figure out is by taking the unique items i want to assign a category to each unique item based on mode of category.
Expected output:
ITEM CATEGORY
1 red saree actual
2 glass lbh
3 bottle actual
please tell me how to find out in python,Thanks in advance
tried:
import pandas as pd
from scipy.stats import mode
data_x = map(mode, data['category'])
I know it is not even related to that, but unable to find how to write the code for that