Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Solutions

The document contains two Python code sets that utilize pandas and matplotlib for data manipulation and visualization. Set A creates a DataFrame for student scores, calculates averages, sorts the data, and saves it to a CSV, while Set B manages salary data, computes total salaries, sorts them, and also saves the results to a CSV. Both sets include plotting functionalities to visualize the data.

Uploaded by

AmazingGamer HQ
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)
2 views

Python Solutions

The document contains two Python code sets that utilize pandas and matplotlib for data manipulation and visualization. Set A creates a DataFrame for student scores, calculates averages, sorts the data, and saves it to a CSV, while Set B manages salary data, computes total salaries, sorts them, and also saves the results to a CSV. Both sets include plotting functionalities to visualize the data.

Uploaded by

AmazingGamer HQ
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
You are on page 1/ 2

SET – A (Python)

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

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

import matplotlib.pyplot as plt

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()

You might also like