select pandas rows by excluding index number

Just use .drop and pass it the index list to exclude.

import pandas as pd

df = pd.DataFrame({"a": [10, 11, 12, 13, 14, 15]})


df.drop([1, 2, 3], axis=0)

Which outputs this.

    a
0  10
4  14
5  15

Not sure if that's what you are looking for, posting this as an answer, because it's too long for a comment:

In [31]: d = {'a':[1,2,3,4,5,6], 'b':[1,2,3,4,5,6]}

In [32]: df = pd.DataFrame(d)

In [33]: bad_df = df.index.isin([3,5])

In [34]: df[~bad_df]
Out[34]: 
   a  b
0  1  1
1  2  2
2  3  3
4  5  5

Tags:

Python

Pandas