Ip Class 12
Ip Class 12
IP Class 12
Q.2- State whether True or False a. A series object is size mutable. (False)
a. A series object is size mutable. b. A Dataframe object is value mutable (True)
b. A Dataframe object is value mutable
OUTPUT:
OUTPUT:
Justification:
In Option a) list elements is repeated two times,
because a list is replicated when multiplied by any
number, it does not allowed vector operation.
In Option b) Series allows vector operation, that is why
each element of the series has been multiplied by 2.
OUTPUT:
Q.26- Consider a series object s10 that stores the import pandas as pd
number of students in each section of class 12 as import numpy as np
shown below. First two sections have been given S10=pd.Series([39,31,32,34,35],index=['A','B','C','D','E'],
task for selling tickets @ Rs.100/- per ticket as a dtype=np.float32)
part of social experiment. Write code to create print("Amount collected by Section A and B (in Rs.)")
the series and display how much section A and B print(S10.head(2)*100)
have collected.
A 39 OUTPUT:
B 31
C 32
D 34
E 35
Q.29- Consider the Series object s12 that stores the import pandas as pd OUTPUT:
contribution of each section, as shown below: import numpy as np
A 6700 idx=[ 'A','B','C','D','E']
B 8000 contr=[6700,8000,5400,3
C 5400 400]
D 3400 s12=pd.Series(contr, idx)
Write code to modify the amount of section 'A' print(s12)
as 8800 and for section 'C' and 'D' as 7700. Print s12['A']=8800
the changed object.
s12[['C','D']]=7700
#or
s12.loc['C':'D']=7700
print(s12)