Issue
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
Solution
Try this:
data.loc[~ data.index.isin(idx)]
Answered By - user1740577
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.