Informatics Practices

Why does following code cause error ?

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

Python Pandas

5 Likes

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'.

Answered By

3 Likes


Related Questions