Question 11

What will the following code result in? pd.Series ([10,20], index = ['A', 'B', 'C'])

What will the following code result in? import pandas as pd pd.Series ([10,20], index = ['A', 'B', 'C'])
  1. AValueError
  2. BNameError
  3. CIndexError
  4. DSyntaxError
Show answerHide answer

Correct answer: (A) ValueError

Explanation

The data list has 2 values but the index has 3 labels. pandas cannot match the lengths, so it raises a ValueError ("Length of values does not match length of index").

From DSSSB TGT Computer Science Practice Set 1

This is question 11 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.