11. Create a Data Frame 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

# initialize list of lists

data = [[‘CAR’,’Maruti’,1000000],[‘AC’,’Hitachi’,55000],[‘AIRCOLLER’,’Bajaj’,12000],

[‘WASHING MACHINE’,’LG’,15000],[‘CAR’,’Ford’,7000000],[‘AC’,’SAMSUNG’,45000],[‘AIRCOLLER’,’Symphony’,20000],[‘WASHING MACHINE’,’Wirlpool’,25000]]

Col=[‘itemcat’,’itemname’,’expenditure’]

# Create the pandas DataFrame

qrtsales = pd.DataFrame(data,columns=Col)

# print dataframe.

print (qrtsales)

qs=qrtsales.groupby(‘itemcat’)

print(‘Result after Filtering Dataframe’)

print(qs[‘itemcat’,’expenditure’].sum())