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'])
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").