I have dataframe
category dictionary
moto {'motocycle':10, 'buy":8, 'motocompetition':7}
shopping {'buy':200, 'order':20, 'sale':30}
IT {'iphone':214, 'phone':1053, 'computer':809}
shopping {'zara':23, 'sale':18, 'sell':20}
IT {'lenovo':200, 'iphone':300, 'mac':200}
I need groupby category and as result concatenate dictionaries and choose 3 keys with the biggest values. And next get dataframe, where at the column category
I have unique category, and in the column data
I have list with keys.
I know, that I can use Counter
to concatenate dicts, but I don't know, how do that to categories.
Desire output
category data
moto ['motocycle', 'buy', 'motocompetition']
shopping ['buy', 'sale', 'zara']
IT ['phone', 'computer', 'iphone']