CBSE Class 12 Informatics Practices Question 122 of 167

Python Pandas — I — Question 12

Back to all questions
12
Question

Question 9

Why does following code cause error ?

s1 = pd.Series(range(1, 15, 3), index = list('ababa')) 
print(s1['ab'])
Answer

The statement s1['ab'] causes an Error because 'ab' is not a single key in the index. The index has individual keys 'a' and 'b', but not 'ab'.