0% found this document useful (0 votes)
13 views2 pages

Temp Py

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Temp Py

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#Name-Rupam Mondal

#CU Roll No -233142-21-0076


#Date-27/02/2925
import pandas as pd

data={'Product':['Carrots','Carrots','Broccoli','Banana','Banana','Beans','Orange','Brocc
fream=[Link](data)
print(fream)

Product Category Quantity Sales_Amount


0 Carrots Vegetable 8 270
1 Carrots Vegetable 8 270
2 Broccoli Vegetable 5 239
3 Banana Fruit 3 617
4 Banana Fruit 4 384
5 Beans Vegetable 5 626
6 Orange Fruit 9 610
7 Broccoli Vegetable 11 62
8 Banana Fruit 8 90
9 Carrots Vegetable 8 270

#Create a pivot table to print the total sales amount of each category

pivot_table = fream.pivot_table(values="Sales_Amount",index=" Category",aggfunc="sum")


print(pivot_table)

Sales_Amount
Category
Fruit 1701
Vegetable 1737

#Create a pivot table to display the total sales amount of each product in a bar chart

pivot_tables = fream.pivot_table(values="Sales_Amount",index="Product",aggfunc="sum")
print(pivot_tables)

Sales_Amount
Product
Banana 1091
Beans 626
Broccoli 301
Carrots 810
Orange 610

#Get the mean, median, minimum sale amount by each product


p_mean=fream.pivot_table(values="Sales_Amount",index="Product",aggfunc="mean")
p_med=fream.pivot_table(values="Sales_Amount",index="Product",aggfunc="median")
p_min=fream.pivot_table(values="Sales_Amount",index="Product",aggfunc="min")
print("mean, sale amount by each product")
print(p_mean)
print(" median sale amount by each product")
print(p_med)
print("minimum sale amount by each product")
print(p_min)

mean, sale amount by each product


Sales_Amount
Product
Banana 363.666667
Beans 626.000000
Broccoli 150.500000
Carrots 270.000000
Orange 610.000000
median sale amount by each product
Sales_Amount
Product
Banana 384.0
Beans 626.0
Broccoli 150.5
Carrots 270.0
Orange 610.0
minimum sale amount by each product
Sales_Amount
Product
Banana 90
Beans 626
Broccoli 62
Carrots 270
Orange 610

You might also like