I have a dataframe in python, and I want to remove the rows that begins with "V10280", "V10281" or "V10282" in col "Variable".
| variable |
|---|
| Capital |
| RM_RIDE |
| … |
| V1028196 |
| V1028197 |
| V1028198 |
| V1028199 |
| V1028200 |
I was thinking of something like this
a = a.loc[a['variable'].str.startswith(("V10280", "V10281", "V10282"))]
but with "not" or "!", such as
a = a.loc[a['variable'].str.startswith(!("V10280", "V10281", "V10282"))]
but this doesn’t work.
Thanks!!
>Solution :
try:
a = a.loc[~a['variable'].str.startswith(("V10280", "V10281", "V10282"))]