I would need to create a new column as follows:
- if the frequency of an item is greater or equal than 5 then set 'best seller';
- if the frequency of an item is between 2 (inclusive) and 5 then set 'ok';
- if the frequency of an item is lower than 2 then set 'bad'.
Suppose that my dataset looks like
Items Date
calzini 2020/02/23
cintura 2020/02/21
maglietta 2020/02/23
maglietta 2020/02/22
cappello 2020/02/23
jeans 2020/02/23
cappello 2020/02/22
maglietta 2020/02/22
maglietta 2020/02/22
jeans 2020/02/22
jeans 2020/02/23
maglietta 2020/02/23
jeans 2020/02/22
jeans 2020/02/23
I would like to have
Items Category
calzini bad
cintura bad
maglietta best seller
maglietta best seller
jeans best seller
cappello ok
jeans best seller
cappello ok
maglietta best seller
maglietta best seller
jeans best seller
maglietta best seller
jeans best seller
jeans best seller
I already determined the frequency of the items as follows:
sold_items=df.groupby(['Items'])['Date'].count().sort_values(ascending=False) # the items should be counted overall, not using a specific Date! It is about how many items were sold
I would like to ask you how to create a new column with those values.