Q. Write a program that stores the sales of 5 fast moving items of a store for each month in 12 Series objects, i.e., S1 Series object stores sales of these 5 items in 1st month, S2 stores sales of these 5 items in 2nd month, and so on.


The program should display the summary sales report like this:

Total Yearly Sales, item-cerise (should display stem of items’ sales over the months)
Maximum sales of item made: <name of item that was sold the maximum in whole year>
Maximum sales for individual items
Maximum sales of item 1 made: <month in which that item sold the maximum>
Maximum sales of item 2 made: <month in which that item sold the maximum>
Maximum sales of item 3 made: <month in which that item sold the maximum>
Maximum sales of item 4 made: <month in which that item sold the maximum>
Maximum sales of item 5 made: <month in which that item sold the maximum>

 


You can understand by Watching video :-

Part 1 :-

Part 2 :-


Answer :-

 

import pandas as pd
indx=["item1", "item2", "item3", "item4", "item5"]

s1 = pd.Series( [ 160, 75, 89, 75, 85 ] , index=indx )
s2 = pd.Series( [ 86, 89, 70, 85, 90 ] , index=indx )
s3 = pd.Series( [ 85, 75, 60, 75, 72 ] , index=indx )
s4 = pd.Series( [ 372, 92, 85, 107, 85 ] , index=indx )
s5 = pd.Series( [ 60, 75, 90, 75, 77 ] , index=indx )
s6 = pd.Series( [ 60, 85, 45, 60, 85 ], index=indx )
s7 = pd.Series( [ 286, 75, 66, 75, 86 ], index=indx )
s8 = pd.Series( [ 60, 72, 200, 70, 75 ], index=indx )
s9 = pd.Series( [ 86, 75, 60, 85, 70 ], index=indx )
s10 = pd.Series( [ 60, 89, 90, 75, 85 ] , index=indx )
s11 = pd.Series( [ 70, 75, 78, 86, 55 ] , index=indx )
s12 = pd.Series( [ 86, 85, 85, 75, 53 ] , index=indx )

yearlySal = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12
print( 'Yearly Sales item-' ,yearlySal )

print('Maximum sales of item made' , end='> ' )
itemlist = list ( yearlySal )

print( indx [ itemlist.index ( max ( itemlist ) ) ] )
print()

List = [ s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 ]  #list of all series
lst=[]

print( "Maximum sales for individual items" )
print()

dic={ 1:s1 , 2:s2 , 3:s3 , 4:s4 , 5:s5 , 6:s6 , 7:s7 , 8:s8 , 9:s9 , 10:s10 , 11:s11 , 12:s12 }
max = 0
for i in range( 5 ) :
    print ( f'Maximum sales of {indx[i]} made: ' , end=' ' )
    max = 0
    for j in dic:
        if max < list ( dic [ j ] ) [ i ] :
            max = list( dic[ j ])[ i ]
            s = j    
    print(s)
 

Output :-

Yearly Sales item- item1    1471
item2     962
item3    1018
item4     943
item5     918
dtype: int64
Maximum sales of item made> item1

Maximum sales for individual items

Maximum sales of item1 made:  4
Maximum sales of item2 made:  4
Maximum sales of item3 made:  8
Maximum sales of item4 made:  4
Maximum sales of item5 made:  2

>>>

8 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post