Home »
Python »
Python Pandas MCQs
What will be the output of following code? Pandas Questions 3
3. What will be the output of following code?
import pandas as pnd
pnd.Series([1,2], index= ['a','b','c'])
- Syntax Error
- Index Error
- Value Error
- None of the above mentioned
Answer: C) Value Error
Explanation:
In the above code, value error will be.
Output:
raceback (most recent call last):
File "/home/main.py", line 2, in <module>
pnd.Series([1,2], index= ['a','b','c'])
File "/usr/lib/python3/dist-packages/pandas/core/series.py", line 430, in __init__
com.require_length_match(data, index)
File "/usr/lib/python3/dist-packages/pandas/core/common.py", line 531, in require_length_match
raise ValueError(
ValueError: Length of values (2) does not match length of index (3)