Reputation: 79
I have a problem in python pandas.
My Excel file input is:
TEAM
001
001
002
003
004
I want to improve my coding, how can I drop TEAM
001, 002, ...
in one command or how can I define a variable
dropteam = '001','002'
to delete 001 and 002?
Like this the but this code is wrong
dropteam001 = replacename[~replacename['TEAM'].str.contains(dropteam)
]
My code:
dropteam001 = replacename[~replacename['TEAM'].str.contains('001')]
dropteam002 = dropteam001[~replacename['TEAM'].str.contains('002')]
Upvotes: 0
Views: 45
Reputation: 323356
You can do two in one time
dropteam = replacename[~replacename['TEAM'].str.contains('001|002')]
Upvotes: 1
Reputation: 8778
You could make a list of the items you want to drop and do:
dropteam001 = replacename[~replacename['TEAM'].isin(newlist)]
Upvotes: 0