Header Ads Widget

Responsive Advertisement

CLASS 12 SERIES WORKSHEET NO 4


CLASS 12 SERIES WORKSHEET NO 4




Question 1) What will be the output of the following: 

import pandas as pd 

D={'a':10,'b':11,'c':12} 

S=pd.Series(D,index=['b','c','d','a']) 

print(S)



Question 2) import pandas as pd 

import numpy as np 

data=np.array(['Mon','Tue','Wed','Thu','Fri','Sat',' Sun']) 

s=pd.Series(data, index=[101,102,103,104,105, 106,107]) 

print(s[[103,105,107]]) 



Question 3) import pandas as pd 

import numpy as np 

data=np.array(['Mon','Tue','Wed','Thu','Fri','Sat',' Sun']) 

s=pd.Series(data) 

print(s[:4]) 

print(s[-4:])



Question 4)import pandas as pd 

first=[7,8,9] 

second=pd.Series(first) 

s1=pd.Series(data=first*2) 

s2=pd.Series(data=second*2) 

print("Series1:") 

print(s1) 

print("Series2:") 

print(s2) 



Question 5) Consider the series s1 and s2 and s3- 

    S1             S2                    S3 

0 10              0 5                 a 3 

1 20             1 10                b 6 

2 30             2 15                c 9 

3 40             3 20                d 10 

4 50             4 25                e 11 

                    5 30 

                    6 35 

Now find the output of the following

i) print(S1+S2) 

ii) print(S1*S3) 

iii) print(S1-S2) 



Question 6) Consider the Series object s12 that stores the contribution of each section, as shown below: 

A 6700 

B 8000 

C 5400 

D 3400 

Write code to create the series and display those sections that made the contribution more than Rs. 5600/-



Question 7) Consider the following Series s3- 

a 1.5 

b 3.0 

c 4.5 

d 6.0 

e 7.5 

Now create the above series and find the output of the following commands

i) print(s3+3) 

ii) print(s3*2) 

iii) print(s3>3.0) 

iv) print(s3[s3>3.0])



Question 8) A Series object trainingdata consists of 2000 rows of data. Write a program to print 


(i) First 100 rows of data 

(ii) Last 5 rows of data




Question 9) Consider the Series object s12 that stores the contribution of each section, as shown below: 

A 6700 

B 8000 

C 5400 

D 3400


Question 10) Write code to modify the amount of section 'A' as 8800 and for section 'C' and 'D' as 7700. Print the changed object.



Question 11) Consider the following code

import pandas 

s1=pandas.Series([2,3,4,5,6],index=['a','b','c','d','e']) 

s1[1:5:2]=345.6 

s1[2:4]= -14.65 

print(s1) 

What will be the output after executing the code. 




Post a Comment

0 Comments