The program should display the summary sales report like this :
Total Yearly Sales, item-wise (should display sum o f items’ sales over the months)
Maximum sales of item made :
Maximum sales for individual items
Maximum sales o f item 1 made :
Maximum sales o f item 2 made :
Maximum sales o f item 3 made :
Maximum sales o f item 4 made :
Maximum sales o f item 5 made :
# Code
import pandas as pd
# Function to help us find the month maximum sales of individual item
def func(name):
m = max(S1[name], S2[name], S3[name], S4[name], S5[name], S6[name], S7[name], S8[name], S9[name], S10[name], S11[name], S12[name])
l = [S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12] # list to check if max sales was in S1 or S2 or s3 and so on
for i in range(len(l)):
if l[i][name] == m:
print(‘Max sales of’, name, ‘made : ‘, i+1) # 1 for S1, 2 for S2 and so on
# Sales of 5 items in each month
S1 = pd.Series([98, 97, 100, 97, 95], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S1 = S1.rename(“S1”)
S2 = pd.Series([96, 93, 99, 95, 90], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S3 = pd.Series([95, 97, 98, 97, 94], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S4 = pd.Series([94, 92, 95, 91, 95], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S5 = pd.Series([98, 97, 100, 97, 105], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S6 = pd.Series([98, 95, 108, 98, 95], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S7 = pd.Series([96, 97, 103, 97, 96], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S8 = pd.Series([98, 94, 104, 99, 97], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S9 = pd.Series([96, 97, 98, 95, 99], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S10 = pd.Series([98, 93, 90, 97, 95], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S11 = pd.Series([99, 97, 100, 96, 105], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
S12 = pd.Series([96, 95, 95, 97, 103], index=[‘item1’, ‘item2’, ‘item3’, ‘item4’, ‘item5’])
y = (S1+S2+S3+S4+S5+S6+S7+S8+S9+S10+S11+S12)
print(‘Total Yearly Sales, item wise :’)
print(y)
print(‘Maximum sales of item made :’, y[y == max(y)].index[0]) # y == max(y) is checking for the item with max sales and then index[0] is returning the index(here item name) of that item
print(‘Maximum salse of individual items : ‘)
for item in S1.index:
func(item)