Home > Blockchain >  Pandas dataframe - 'bool' object is not subscriptable
Pandas dataframe - 'bool' object is not subscriptable

Time:06-22

I am trying to retrieve records in a dataframe that do not have matching IDs in a separate list. Essentially, I want to drop any records from the dataframe where UniqueId matches any Ids in the list PM_docIDs:

df = df[~df['UniqueId']].isin((PM_docIDs).index, inplace=True)

This produces the following error:

In  [35]:
Line 4:     df = df[~df['UniqueId']].isin((PM_docIDs).index, inplace=True)

TypeError: 'bool' object is not subscriptable

Is there an easier way to do this or is there something I can do to fix the snippet aboveso I don't get the TypeError?

CodePudding user response:

You're close, but your syntax is a little jumbled. How about this?

df = df[~df['UniqueId'].isin(PM_docIDs.index)]
  • Related