Informatics Practices

Why does the following code cause error?

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

Python Data Handling

2 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