Question: I'm trying to filter a Dataframe based on the length of the string in the index. In the following example I'm trying to filter out everything but `Foo Bar`:

```
index    Value
Foo      1
Foo Bar  2
Bar      3

In: df[df.index.apply(lambda x: len(x.split()) > 1] 
Out: AttributeError: 'Index' object has no attribute 'apply'

```

Is there any way to perform this operation directly on the index rather than resetting the index and applying the function on the new column?

Answer: 
We do not need `apply` here 

```
df[df.index.str.count(' ')==1]

```

To fix your code `map`

```
df[df.index.map(lambda x: len(x.split()) > 1)]

```
I'm having success with the following:

```
>>> df[df.index.str.split().str.len() > 1]
         Value
Foo Bar      2

```

Basically split the string and then use len() to count the number of occurrences. This has the benefit of allowing you to split however you want and filter however you want, without using apply.