'PANDAS : How to filter a dataframe based on index (mixed type) )

I want to filter my dataframe based to the type of my index. My index has string, NaT or date. I only want to keep the rows with date in the index.

I tried the below but it doesn't work. I get

keyError: False

df = df[isinstance(df.index, datetime)==True]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source