You are on page 1of 4

INFORMATICS PRACTICES CLASS XII

TOPIC : SERIES WORKSHEET-2

Q1. What is a Series and how is it different from a 1-D array, a list and a dictionary?
Ans:
A Series is a one-dimensional array containing a sequence of values of any data type
(int, float, list, string, etc) which by default have numeric data labels starting from zero.
Series vs 1-D array
Series can have default as well as predefined index labels whereas a numpy 1-d array
has only default indexes
Series can contain values of any datatype whereas arrays can contain elements of same
data type
Series vs List
Series can have default as well as predefined index labels whereas a list has only default
indexes
Series vs dictionary
Series elements can be accessed using default indexes as well as its row labels
Whereas dictionary elements cannot be accessed using default indexes. They hv to be
accessed using the predefined keys.

Q2. Differentiate between head() and tail().


Ans: head(): top 5
head(10): top 10
tail(): bottom 5
tail(2): bottom 2
NOTE: DOES not give the data in the reverse order while using tail()

Q3. Differentiate between size attribute and count() in Series with an example.
Ans:
size is an attribute of Series which gives the number of values in the Series.
>>> s=pd.Series([7,9.6,'sush'])
>>> s.size
3
WHEREAS
count() is a function that returns the number of non NaN values from the
series
>>> s=pd.Series([7,8,np.nan,"piyush",90])
>>> s.count()
4
Q4. Create a series Vowels1 having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ having
values [2,5,6,3,8] respectively.
Ans:
Q5. Change the index labels of Vowel1 to ‘A’,’E’,’I’,’O’,’U’.
Q6. Give the name “VOW” to the index of the above created series.
Ans 5 and 6

Q7. Display the content of the series vowel in reverse order


Ans:

Q8. Write statement to check whether the series Vowels1 is empty or not.
Ans:

Q9. Write statement to Retrieve and print alternate elements from the given series,
starting from index “E”.
Ans:

Q10. Give the output of the following code.

Ans:
0 18.0
1 38.0
2 62.0
3 85.0
4 50.0
Q11. Given a Pandas series called Series S having 10 elements, the command which will
display all elements from index number 2 to 7 with step size 2.
Ans: print ( S [ 2 : 8 : 2 ] )
Q12. Given the following Series S1:

Write the command to find the elements which are greater than 40.
Ans: print(s [ s > 40 ] )

Q13. Fill in the blanks:


a) ___Series______ and _dataframes___ are two main data structures in
Pandas library/package.
b) _________pip_________ command is used to install the pandas
library/package.
c) _positional__ and ____label_____are the two types of indexes used in Series.
d) When __positional______indices are used for slicing, the value at end index
position is excluded ( not included)
e) Value of Positional indexes start from___0_____.
f) To use the data structures of the Python Pandas one needs to
____import________ the pandas library.
g) __pandas____ and ___matplotlib______ are some Python libraries/packages.
Q14. Consider two series S1 and S2
S1 S2
Delhi 40 Mumbai 30
Kolkata 60 Kolkata 10
Jaipur 15 Patna 24

What will be output of


(a)S1.add(S2)
(b) S1+s2
(c) S1.add(S2,fill_value=2)
Ans:

You might also like