Python Solutions
Python Solutions
import numpy as np
import pandas as pd
std=pd.DataFrame({'IP':[45,23,30,41],'Eco':[39,29,32,45],'Eng':[48,np.NaN,36,42]},index=['Rohit','Suman'
,'Nitish','Ramesh'])
print(std)
std.loc[len(std)]=[67,78,65]
std1=std.rename(index={4:'Seema'})
print(std1)
std1['Average']=std1.sum(axis=1)/3
print(std1)
newstd=std1.sort_values(by='Average',ascending=False)
print(newstd)
print(newstd.max(axis=0))
print(newstd.shape)
newstd.to_csv("Practical.csv")
newstd.plot(kind='bar')
plt.show()
SET – B (Python)
import numpy as np
import pandas as pd
ndf=pd.DataFrame({'Basic':[15000,20000,15000,18000],'HRA':[8000,7500,np.NaN,7800],'DA':[5000,4500
,6000,5500]},index=['Arun','Anu','Benit','Cilona'])
print(ndf)
ndf.loc[len(ndf)]=[18000,6000,7000]
ndf1=ndf.rename(index={4:'Piyush'})
print(ndf1)
ndf1['Total Salary']=ndf1.sum(axis=1)
print(ndf1)
ndf2=ndf1.sort_values(by='Total Salary',ascending=True)
print(ndf2)
print(ndf2.min(axis=0))
ndf3=ndf2.drop('Benit')
print(ndf3)
ndf3.to_csv("Exam.csv")
ndf3.plot(kind='line')
plt.show()