-1

I was trying to drop the rows with id equals anything in the ND_Before0_Opioid.id.unique() list with the following code:

ND = data[~data.id.isin([ND_Before0_Opioid.id.unique()])]

But nothing was changed, ND is still exactly the same with original data

roganjosh
  • 12,594
  • 4
  • 29
  • 46
  • 1
    That would be expected if the columns have different `dtypes`, for example. There's nowhere near enough info here to be sure, you need a [mcve] – roganjosh Sep 24 '19 at 19:18

1 Answers1

0

roganjosh comment is on point. The .isin does't work if dtypes of both lists aren't the same.

Try this:

ND = data[~data.id.astype(int).isin(ND_Before0_Opioid.id.astype(int).unique())]