Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Series Attributes, Methods & Filtering

1) Given a Series ‘s’:

0 8
1 15
2 16
3 4
4 3
dtype: int64

Write the output for the following python statements:


i) print(s[s>15])
ii) print(s<15)

2) Write the Python statement to display all the members of the series objects given.

Num
A 5
B 8
C 15
D 2
E 12
dtype: int32

Also write the statement to show the dimensionality of its number of elements
presents.

3) Predict the output of the following from the given series ‘S’:

import pandas as pd
import numpy as np
S = pd.Series(np.array([8,5,np.nan,12,5,15]))

i) S.shape
ii) S.ndim
iii) S.nbytes
iv) S.size
v) S.index.values
vi) S.values
vii) S[S%2==0]
viii) S.loc[[True, False, False, True, True, False]]
ix)
for i in S.index:
print(i, end = ' ')

4) Write the python statement to display the non-nan values from the series ‘sobj’
given.

0 8
1 5
2 15
3 12
4 5
5 15
dtype: int32

5) Write the python program to check if the series ‘odd’ has missing values or not.

6) Write the python program to check if the series ‘sobj’ is empty.

7) Given a series ‘n’

a 8.0
b 15.0
c 4.0
d NaN
e 6.0
f 7.0
g 5.0
h 9.0
dtype: float64

Write the output of the following:

i) print(n.head(3))
ii) print(n.tail())
iii) print(n.count())
iv) print(n.hasnans)
v) print(n.dtypes)

8) Write the Python to statement to name the given series as ‘even’ also write the
output

0 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
dtype: int64

9) Write the python statement to set the index of the series given with labels a, b, c
and d. Also name the index as ‘alpha’

S:

0 9
1 6
2 3
3 2
dtype: int64

You might also like