CBSE Class 12 Informatics Practices Question 49 of 167

Python Pandas — I — Question 14

Back to all questions
14
Question

Question 14

What will be the output of the following code ?

import pandas as pd
myser = pd.Series([0, 0, 0])
print(myser)
  1. 0 0
    0 0
    0 0
  2. 0 1
    0 1
    0 2
  3. 0 0
    1 0
    2 0
  4. 0 0
    1 1
    2 2
Answer

0 0
1 0
2 0

Reason — The code creates a pandas Series object myser with three elements [0, 0, 0], and when we print the Series, it displays the index along with the corresponding values. Since the Series is created with default indexes (0, 1, 2), the output shows the index values (0, 1, 2) along with the corresponding values (0, 0, 0).