Class 12th CBSE IP
Write a python program to create a DataFrame quarterly sales where each row contains the item category, item name and expenditure. Group the rows by the category and print the total expenditure per category.
Solution: –
import pandas as pd df=pd.DataFrame() df['item category']=['c1','c2','c3','c4'] df['item name']=['pen','pencil','bottle','lunchbox'] df['expenditure']=[1000,2000,3000,4000] print(df) p1=df.pivot_table(index='item category',values='expenditure',aggfunc=sum) print(p1)
Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable
Popular Videos
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer