0% found this document useful (0 votes)
4 views7 pages

Code

a coding project for class 12 i.p

Uploaded by

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

Code

a coding project for class 12 i.p

Uploaded by

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

1.

import pandas as pd
l1={'Khushi':42536,'Shambhavi':67577,'Bhavika':64355}
s=pd.Series(l1)
print(s)

2.

import pandas as pd

ser=pd.Series(64559,index=range(1,6,2))

print(ser)

3.

import pandas as pd

ser=pd.Series(64559,index=range(1,6,2))

print(ser)

4.

import pandas as pd
import numpy as np
s=["Shambhavi","Khushi",np.NaN,"bhavika",np.NaN,"Abhi",np.NaN]
b=pd.Series(s)
b.name='Students'
b.index.name='Series'
print(b)
print(b.index)
print(b.index.name)
print(b.values)
print(b.dtype)
print(b.shape)
print(b.nbytes)
print(b.ndim)
print(b.size)
print(b.hasnans)
print(b.empty)
print(b.name)
5.

import pandas as pd

import numpy as np

Ser1=pd.Series([1.8,-2.75,-3.25,45.05,5.5])

n=[1.5,12.50,24.00,14.50,55.50]

i=['A','B','C','D','E']

Ser2=pd.Series(n)

Ser3=pd.Series(n,i)

#print(Ser1,Ser2,Ser3)

'''print(Ser1+198)

print(Ser1*29)

print(Ser1**5)

print(Ser1>34)

print(Ser2+878)

print(Ser2*19)

print(Ser2**2)

print(Ser2>1.5)

print(Ser3+5607)

print(Ser3*16)

print(Ser3**4)

print(Ser3>9)'''

print(Ser1*Ser2)

print(Ser2+Ser1)

print(Ser2/Ser1)

print(Ser1-Ser3)
6. import pandas as pd

STUDS=pd.Series([56,76,92,89,94,72,91,90,95,93])

a.STUDS.index=['Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Frank', 'Grace', 'Hannah', 'Isaac', 'Judy']

b.print(STUDS[STUDS>90])

c..top_3_scorers = STUDS.sort_values(ascending=False).head(3)

print(top_3_scorers)

d.STUD_NEW= STUDS.sort_values(ascending=False)

print(STUD_NEW)

E.STUDS[1:9:6] = 95

print(STUDS)

Q7.

import pandas as pd

r=[79.50,'Cricekt','Ruchika']

n=[83.75,'Badminton','Neha']

m=[74.00,'Football','Mark']

j=[89.00,'Kabaddi','Jamal']

g=[88.50,'Athletics','Gurjyot']

S_DATA=pd.DataFrame((r,n,m,g,j),columns=['Marks','Sport','Students'])

print(S_DATA)

8.

people={'Sales':{"name":'Rohit','age':24,'gender':'Male'},

'Marketing':{"name":'Shambhavi','age':27,'gender':'Female'}}

df1=pd.DataFrame(people)

print(df1)

9.

A={'Rollno.':12104,'Name':'Sakshi','Marks':67}
B={'Rollno.':12213,'Name':'Rudra','Marks':97}

C={'Rollno.':12306,'Name':'Gautam','Marks':77}

D={'Rollno.':12436,'Name':'Ruby','Marks':72}

top=[A,B,C,D]

df1=pd.DataFrame(top)

print(df1)

10.

import pandas as pd

l=[[30,80,90],[307,68,990],[9087,760,345],[990,8976,897],[234,675,8]]

df=pd.DataFrame(l,index=[row1,row2,row3,row4,row5])

print(df)

11.

import pandas as pd

import numpy as np

ar=np.array([[101,102,103],[111,112,113],[121,122,123]])

df=pd.DataFrame(ar)

print(df)

12.

import pandas as pd

import numpy as np

days=['Monday','Tuesday','Wednesday','Thrusday','Friday']

classes=[6,0,3,0,8]

dc={'Days':days,'No of Classes':classes}

df=pd.DataFrame(dc,index=[True,False,True,True,False])

print(df)

13.
1.
RESULTSHEET.rename(index={'Sharad':1,'Mansi':2,'Kanika':3,'Ramesh':4,'Ankita':5,'Pranay':6}
,inplace=True)

print(RESULTSHEET)

2.

RESULTSHEET.rename(columns={'UT1':'Term1','Half
Yearly':'Term2','UT2':'Term3','Final':'Term4'},inplace=True)

print(RESULTSHEET)

3.

RESULTSHEET['Internal Assessment']=['A', 'A','B','A','C','B']

print(RESULTSHEET)

4.

RESULTSHEET.loc['Asatha',:]=[49, 56, 75,58]

print(RESULTSHEET)

5.

del RESULTSHEET['UT1']

print(RESULTSHEET)

6.

RESULTSHEET=RESULTSHEET.drop(['Kanika'])

print(RESULTSHEET)

7.

RESULTSHEET.rename(index={'Mansi':'Mahak'},inplace=True)

print(RESULTSHEET)

8.

print(RESULTSHEET.loc['Mansi'])

9.
print(RESULTSHEET.loc[['Sharad':’Pranay’,['Half Yearly','Final']])

10.

print(RESULTSHEET.loc['Mansi':'Ankita',:])

11.

print(RESULTSHEET.loc['Mansi':'Ankita',['UT1','UT2']])

12.

print(RESULTSHEET.loc[['Kanika','Ankita'],['Half Yearly','Final']])

13.

print(RESULTSHEET.head(3))

14.

print(RESULTSHEET.tail(4))

Que.14

import matplotlib.pyplot as plt

Years= [2000,2004,2005,2006,2008,2010,2012,2014,2015,2016,2018,2020]

Salary= [10000,14000,18000,20000,24000,28000,30000,34000,38000,40000,44000,48000]

plt.xlabel('Year')

plt.ylabel('Salary')

plt.title('Salary Hike of an Employee')

plt.plot(Years,Salary,'r',linewidth=4)

plt.plot(Years,Years,color='r',label='line1')

plt.legend(loc='upper left')

plt.show()

ply.savefig(“multibar.pdf”)

15.
import matplotlib.pyplot as plt

Category = ['gold', 'silver', 'bronze']

Medal = [10,15,8]

plt.bar(Category,Medal,color=['gold','silver','brown'])

plt.xlabel('Medal')

plt.ylabel('Medal Type')

plt.title('Indian Medal Tally in Olympics')

plt.bar("Medal",'Medal',color='gold',label='goldmedal')

plt.bar("Medal",'Medal',color='silver',label='silvermedal')

plt.bar("Medal",'Medal',color='brown',label='bronze')

plt.legend(loc='upper left')

plt.show()

plt.savefig("aa.jpg")

You might also like