I have a dataframe. It contains
df['article_id']. I'm using
to_sql function with
sqlalchemy to insert into my database. However, sometimes I have duplicate records that I want to remove before inserting.
This is my list:
usedIDs =  select_st = select([article_table]) res = conn.execute(select_st) for _row in res: clean = int(_row) usedIDs.append(clean) usedIDs
[1202623831, 1747352473, 1748645480, 1759957596, 1811054956, 1812183879, 1816974229, 2450784233, 2579244390, 2580336884]
What i've tried:
df[~df.isin(usedIDs)] df.drop(usedIDs, axis=0)
And this does not work. However when I hardcode it like below, it does work.
df = df[~df.article_id.isin(['1202623831','1747352473'])]
Error is either
KeyError: not found in axis.
How can I drop the rows from my dataframe where
df['article_id'] is in