0% found this document useful (0 votes)
10 views15 pages

Import

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 15

import matplotlib .

pyplot as plt
Subject = ['Physics','Chemistry','Maths','English','IP']
percentage =[89,90,97,90,99]
plt.bar(Subject, percentage,align
="center",color='purple')
plt. xlabel('SUBJECT NAME')
plt. ylabel ('PASS PERCENTAGE')
plt.title('RESULT ANALYSIS')
plt.show ()

import matplotlib .pyplot as plt


import numpy as np
sub = ['1st','2nd','3rd']
per_sc = [99,96,90]
per_com = [89,95,93]
per_hum =[70,80,90]
x=np.arange (len(sub))
plt.bar (x,per_sc,label ='SCIENCE' ,width = 0.25, color =
'blue')
plt.bar (x+0.25,per_com,label ='COMMERCE' ,width =
0.25, color = 'pink')
plt.bar (x+0.50,per_hum,label ='HUMANITIES' ,width =
0.25, color = 'yellow')
plt.xticks (x,sub)
plt.xlabel ('position' )
plt.ylabel ('percentage' )
plt.title('SUBJECT ANALYSIS')
plt.legend()
plt.show()

import matplotlib. pyplot as plt


import pandas as pd
data ={'name' :
['Anna','Eric','Audery','Sebastian'],'Height' :
[60,72,62,76],
'weight':[46,75,50,79] }
df = pd . DataFrame (data)
df.plot(kind='hist')
plt.show ()

import matplotlib.pyplot as plt


import numpy as np
languages = ('Dotnet','Java','Python','C','C++')
y_pos = np.arange(len(languages))
performances = [ 9,7,5,9,8]
plt.bar(y_pos , performances ,align ='center',
color ='red')
plt.xticks(y_pos,languages)
plt.ylabel('usage')
plt.title('programming language usage')
plt.show()
import matplotlib.pyplot as plt
x1 = [20,40,60]
y1 = [10,20,30]
x2 = [30,60,90]
y2 = [20,80,70]
plt.xlabel ('X-AXIS')
plt.ylabel ('Y-AXIS')
plt.title("TWO OR MORE LINES WITH DIFFERENT
WIDTHS AND COLORS WITH SUITABLE LEGENDS")
plt.plot(x1,y1, color = 'maroon' , linewidth =3, label =
'line1-width-3')
plt.plot(x2,y2, color = 'plum' ,linewidth=2, label ='line2-
width-2')
plt.legend()
plt.show()
import pandas as star
import numpy as np
print ('1. **creation of empty series** ')
print ('2. **creation of series using list** ')
print ('3. **creation of series using range** ')
print ('4. **creation of series using dict** ')
print ('5. **creation of series giving labelled index** ')
print ('6. **creation of series using numpy** ')
print ('7. **creation of series using constant value** ')
print ('8. **creation of series using string** ')
print ('9. **creation of series using integer value and
string as index** ')
print ('10. **creation of series using string value and
integer as index** ')
print ('11. EXIT')
while True :
ch = int(input("Enter your choice between 1 to 10 :
"))
##Creation of empty series
if ch==1 :
ser1 = star.Series(dtype=int)
print(ser1)
##Creation of series using list
elif ch==2 :
ser2= star.Series ([10,12,12.15,18])
print (ser2)
##Creation of series using range
elif ch==3 :
ser3= star.Series (range(5))
print (ser3)
##Creation of series using dict
elif ch==4 :
dict2 ={'JAN':31,'FEB':28,'MAR':31}
ser4 = star.Series(dict2)
print (ser4)
##Creation of series giving labelled index
elif ch==5 :
ser5 = star.Series ([10,11,12,13], index = [1,2,3,4])
print (ser5)
##Creation of series using numpy
elif ch==6 :
ar1= np.array([12,15,18])
ser6 = star.Series(ar1)
print (ser6)
##Creation of series using constant values
elif ch==7 :
ser7 = star.Series (12,index =[1,3,5,7])
print (ser7)
##Creation of series using string
elif ch==8 :
ser8 = star.Series('Welcome to APS', index
=[1,2,3,4])
print (ser8)
##Creation of series using integer value and string
value as index
elif ch==9 :
ser9= star.Series ([12,13,14,15], index
=['a','b','c','d'])
print (ser9)
elif ch==10 :
##Creation of series string value and integer as index
ser10 = star.Series(['a','b','c','d'], index =[1,2,3,4])
print (ser10)
##Exit
elif ch==11 :
quit ()
else : print ("## PLEASE ENTER A VALID INPUT: ##")
if input ( "DO YOU WANT TO CONTINUE (y/n): ")!= 'y':
print ("** YOUR PROGRAM IS OVER , THANK YOU
FOR WORKING **")
break

import pandas as pd
import numpy as np
print (' 1. **creation of empty dataframe**' )
print (' 2. **creation of dataframe using series**')
print ('3. **creation of dataframe using list of dict**')
print ('4. **creation of dataframe using dict of list**')
print ('5. **creation of dataframe using dict of
series**')
print ('6. **creation of dataframe using list**')
print ('7. **exit**')
while True :
ch = int (input("ENTER YOUR CHOICE : "))
## Creation of empty dataframe
if ch==1:
d1 = pd.DataFrame ()
print (d1)
##creation of database using series
elif ch ==2 :
Ser1 = pd.Series ([9,12,15,18])
DF1 = pd.DataFrame (Ser1)
print (DF1)
##Creation of database using list of dictionaries
elif ch ==3:
D={'a':30 ,'b':50,'c':70}
D1 ={'a':30 ,'b':50,'c':70}
DF2 = pd.DataFrame ([D,D1])
print(DF2)
##Creation of dict of list
elif ch ==4 :
STUDENT ={'NAME' :
['REN','CHAR','ALEX','HAZEL'],'ACCOUNTANCY' :
[90,95,90,92]}
DF3 = pd.DataFrame (STUDENT)
print(DF3)
##Creation of dataframe using dict of series
elif ch ==5 :
S =pd.Series (['REN','CHAR','ALEX','HAZEL'])
ACC =pd.Series ([90,95,90,92])
student_result ={"NAME":
S,"ACCOUNTANCY" :ACC}
DF4 = pd.DataFrame(student_result)
print (DF4)
##Creation of dataframe using list
elif ch==6 :
L1=[15,30,45,60]
DF5=pd.DataFrame (L1)
print (DF5)
##Exit
elif ch==7 :
quit ()
else : print ("##PLEASE ENTER A VALID INPUT : ##")
if input("DO YOU WANT TO CONTINUE(y/n): ")!='y' :
print ("** YOUR PROGRAM IS OVER<THANK YOU
FOR WORKING **")
break

import pandas as pd
p = pd.Series([98,86,74,65])
print(p)
result = p.quantile(0.75)
print("75th percentile of series is : " , result)
print("The elements that are above 75th
percentile :",p[p>75])
import pandas as pd
dic ={'Category':
['MEDICAL','GROCERRY','CLOTHES'],'ITEM NAME':
['ANTISEPTICS','FLOUR','SKIRTS'],'EXPENDITURE':
[100,200,500]}
quaterly_sales =pd.DataFrame(dic)
print (quaterly_sales)
C=quaterly_sales.groupby ('Category')
print('Result after filtering')
print(C.sum())

import pandas as pd
sales ={'item':[90,54,38,70],'qty':[4,7,2,6],'price':
[5000,3050,6850,1250]}
df1=pd.DataFrame(sales)
print(df1 ['price'].describe().round(4))
import pandas as pd
dic ={'Class' : ['VI','VII','VII','IX','X','XI','XII'],'PASS' :
[190,185,180,175,190,160,195]}
RESULT =pd.DataFrame (dic)
print(RESULT)
print(RESULT.dtypes)
print(RESULT.shape)

import pandas as pd
dic ={'NAME':
['LIA','LIA','EDWARD','MAGNUS'],'MarksIP' :
[80,80,90,98]}
MARKS = pd.DataFrame (dic)
duplicate = MARKS[MARKS.duplicated(keep=False)]
print (duplicate)

import pandas as pd
profit ={'TCS':{'QTR':10000, 'QTR1':10050 },'WIP' :
{'QTR': 9000,'QTR1' : 9050}}
df =pd.DataFrame (profit)
print(df)
print ('Column wise sum in df is:', df.sum (axis=0))
print('column wise with minimum mean
is:',df.mean(axis =0))

import pandas as pd
dic ={'NAME':
['LIA','LIA','EDWARD','MAGNUS'],'MarksIP' :
[80,80,90,98]}
MARKS = pd.DataFrame(dic)
print (MARKS.nlargest(3,['MarksIP']))

import pandas as pd
PROFIT ={'a':[2.5,3.5],'b':[1.25,3.75],'c':[2.25,1.75]}
df =pd.DataFrame(PROFIT)
print(df)
print(df.mean(axis =1))
print(df.sub(df.mean(axis=1),axis =0))

import pandas as pd
dic ={'DATA':[-6,9,6,4,-2],'DATA2':[5,7,-1,-8,-3]}
df =pd.DataFrame (dic)
print(df)
print('df after replacing negative value with 0:')
print (df [df<0]+0)

import pandas as pd
empdata = {'empid':[491,492,493,494],'ename':
['NOAH','BELLA','ARTHUR','HANNAH']}
df =pd.DataFrame(empdata)
print(df)
df=df.fillna({'ename':999})
print(df)

You might also like