I have a dataframe with index is string name like 'apple' etc.

Now I have a list

name\_list=['apple','orange','tomato']

I'd like to filter dataframe rows by selecting rows with index is in the above list

```

df=df.loc[df.index.str.isin(name_list)]

```

then I got an error of

```
AttributeError: 'StringMethods' object has no attribute 'isin'

```