【python】【报错】TypeError: 'RangeIndex' object is not callable

1. Problem description

When I want to use the .index method to find the subscript of an element, I get an error:

>>> standard_name.index('Zimbabwe')
Traceback (most recent call last):
  File "<pyshell#46>", line 1, in <module>
    standard_name.index('Zimbabwe')
TypeError: 'RangeIndex' object is not callable

ViewdealThe data type is found to be of Series type

>>> type(standard_name)
<class 'pandas.core.series.Series'>

2. Problem solving

willdealAfter converting to the list type, use the .index method again , and it succeeds

>>> list(standard_name).index('Zimbabwe')
218

Guess you like

Origin blog.csdn.net/why_not_study/article/details/103318261