I need to create column as dictionary using existing column. df:
Period Category Sub-Category
FY18Q1 Footwear Shoes
FY18Q2 Footwear Sandal
FY18Q1 Footwear Shoes
FY18Q3 Footwear Boots
FY18Q1 Clothing Shirt
FY18Q2 Clothing Trouser
FY18Q1 Clothing Shirt
FY18Q3 Clothing Shirt
I want to create a two new column based on Category Level. A. Count of Sub-Category on Category Level. B. Sub-Category based on latest Period.
Period Category Sub-Category freq Latest_freq
FY18Q1 Footwear Shoes {shoes:2,Sandal:1,Boots:1} Boots(FY18Q3)
FY18Q2 Footwear Sandal {shoes:2,Sandal:1,Boots:1} Boots(FY18Q3)
FY18Q1 Footwear Shoes {shoes:2,Sandal:1,Boots:1} Boots(FY18Q3)
FY18Q3 Footwear Boots {shoes:2,Sandal:1,Boots:1} Boots(FY18Q3)
FY18Q1 Clothing Shirt {Shirt:3,Trouser:1} Shirt(FY18Q3)
FY18Q2 Clothing Trouser {Shirt:3,Trouser:1} Shirt(FY18Q3)
FY18Q1 Clothing Shirt {Shirt:3,Trouser:1} Shirt(FY18Q3)
FY18Q3 Clothing Shirt {Shirt:3,Trouser:1} Shirt(FY18Q3)