1

I am trying to index rows of Dataframe with rows not included in the list. For example, here we extract rows 1,2 and 4 of the dataframe (data). But I would like to extract everything but those rows (say rows 3, 5, and 6):

idx = [1,3,4]
subset= data.iloc[idx , :]

So far, I tried this but get the error below:

try = data.iloc[not idx, :]
ValueError: Location based indexing can only have [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types
ALollz
  • 57,915
  • 7
  • 66
  • 89
maximus
  • 335
  • 2
  • 16

1 Answers1

2

Try this:

data.loc[~ data.index.isin(idx)]
I'mahdi
  • 23,382
  • 5
  • 22
  • 30