node1 node2 weight date
3 6 1 2002
2 7 1 1998
2 7 1 2002
2 8 1 1999
2 15 1 2002
9 15 1 1998
2 16 1 2003
2 18 1 2001
I want to delete rows which have the values [3, 7, 18].These values can be in any of the rows node1 or node2.
df[(~df['node1'].isin([3,7,18])) & ~df['node2'].isin([3,7,18])]