In this section we will create a new column for frequency of each product
df['Frequency of Product'] =df['Product line'].map(df['Product line'].value_counts())
df.head(4)
</style>
Invoice ID
Branch
City
Customer type
Gender
Product line
Unit price
Quantity
Tax 5%
Total
Date
Time
Payment
cogs
gross margin percentage
gross income
Rating
Frequency of Product
0
750-67-8428
A
Yangon
Member
Female
Health and beauty
74.69
7
26.1415
548.9715
1/5/2019
13:08
Ewallet
522.83
4.761905
26.1415
9.1
152
1
226-31-3081
C
Naypyitaw
Normal
Female
Electronic accessories
15.28
5
3.8200
80.2200
3/8/2019
10:29
Cash
76.40
4.761905
3.8200
9.6
170
2
631-41-3108
A
Yangon
Normal
Male
Home and lifestyle
46.33
7
16.2155
340.5255
3/3/2019
13:23
Credit card
324.31
4.761905
16.2155
7.4
160
3
123-19-1176
A
Yangon
Member
Male
Health and beauty
58.22
8
23.2880
489.0480
1/27/2019
20:33
Ewallet
465.76
4.761905
23.2880
8.4
152
In this section we will create a dataframe derived from the major dataframe 'df' to focus on frequency of product and the product
forbranchfreq=df[['Product line','Frequency of Product']]
forbranchfreq.head(5)
Product line
Frequency of Product
0
Health and beauty
152
1
Electronic accessories
170
2
Home and lifestyle
160
3
Health and beauty
152
4
Sports and travel
166
In this section we will group the frequencies in order to derive unique values of the product that we can plot sefully later and also sort it from first to last
forbranchfreq100=forbranchfreq.groupby(['Product line']).sum()
forbranchfreq120=forbranchfreq100.sort_values(by=['Frequency of Product'], ascending=False)
forbranchfreq120=DataFrame.drop_duplicates(forbranchfreq120)
forbranchfreq120.head(3)
Frequency of Product
Product line
Fashion accessories
31684
Food and beverages
30276
Electronic accessories
28900
In this section we wil plot the new grouped and sorted dataframe of product and the frequency. We derive from this that Fashions and accessories come first and Health and beauty products come last
this can inform supermarket management to put rackets of fashions and accesories at the door of the supermarket
because they are a best-seller