0% found this document useful (0 votes)
27 views5 pages

Pandas1 Rev

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Pandas1 Rev

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

To create any kind of Series object, which method you may use:

a) Pandas

b) Series

c) Both (a) and (b)

d) none of these

2. To get total number of elements of a series, you may use

a) len()

b) count()

c) Both (a) and (b)

d) none of these

3. To display last 5 rows of a Series object S, you may use:

a) S.tail()

b) S.head(6)

c) S.head(0:4)

d) none of these

4. Missing data in Pandas object is represented through

a) Null

b) None

c) Missing

d) NaN
5. The data label associated with a particular value of Series is called its…………

a) Data Value

b) Index

c) Value
d)None of the above

6. Which of the following code will generate the following output?


Jan 31
Feb 28
Mar 31
dtype: int64

a.
import pandas as pd
S1 = pd.Series(data = [31,28,31], index=["Jan","Feb","Mar"])
print(S1)

b.
import pandas as pd
S1 = pd.Series([31,28,31], index=["Jan","Feb","Mar"])
print(S1)

c. Both of the above

d. None of the above

7. Write the output:

import pandas as pd

S1 = pd.Series(data = range(31, 2, -6), index = [x for x in "aeiou" ])


print(S1)
a.
a 31
e 25
i 19
o 13
u7
dtype: int64
b.
a 31
e 25
i 19
o 13
dtype: int64

c. Error
d. None of the above

8. What type of error is returned by following code?


import pandas as pd
S1 = pd.Series(data = (31, 2, -6), index = [7, 9, 3, 2])
print(S1)
a. SyntaxError
b. IndexError
c. ValueError
d. None of the above

9. Fill in the blank to get the ouput as 3


import pandas as pnd
S1=pnd.Series([1,2,3,4], index = ['a','b','c','d'])
print(S1[___________])
a. ‘c’
b. 2
c. c
d. All of the above

10. Write the statement to get NewDelhi as output using positional index.
import pandas as pd
S1 = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'],
index=['India', 'USA', 'UK', 'France'])
a. print(S1[0])
b. print(S1[‘India’])
c. Both of the above
d. print(S1.India)

SECTION-II State True/False


1. A Series is a 1-Dimensional object that can hold any data type such as integers,
floats and strings.
2. A series has only one axis.

3. A series object is value mutable

4. Series object’s indexes are always from 0 to n-1

5. You cannot change the index of Series’s object.

SECTION-III Answers the following questions


1. Write command to print the following details of a Series object “study”

a) if the series is empty.

b) indexes of the series

c) the datatype of the underlying data

d) If the series stores any NaN values.

2. Given the following series objects:

a) What will be the result of S1+S2.


b) b) What will be the result of S1-S2.
3.A series object “S8” stores the bonus of different employees, like:
a) Write a statement to create the above series
b) Write a statement to display all employees who are getting salary mo
4. Consider a series object “study”, created using the following statements:
study=pd.Series([11,23,31,61,87,93], index=[‘a’,’b’,’c’,’d’,’e’,’f’])
Based on the series object, write statements to do the following:
a) Retrieve the third element and print it.
b) Retrieve and print the first three elements
c) Retrieve and print the last two elements
d) Retrieve and print alternate elements, starting from index ‘b’
e) Retrieve and print all elements where value is even

5. Create a series with 5 elements, then find square of each even elements an
find cube of each odd elements.

SECTION-IV Write the code for the following questions :


1)Create a Series with 5 values and indexes, then:
a) Sort the series element by descending order of elements.
b) Sort the series index by ascending
2. Difference between Series and DataFrame.
3. Write any one difference between list and series.

You might also like