Consider a Pandas Dataframe like:
df = pd.DataFrame([[0,2],[1,0],[7,99]],index=[3,4,8], columns = ["R1","R2"])
Giving:
R1 R2
3 0 2
4 1 0
8 7 99
When I want to remove a row via a condition on a value I either use
df = df.drop(df[df["R1"] == 1].index)
Or
df = df.drop(df.index[np.where(df["R1"] == 1)[0]])
Or
df = df.drop(df.loc[df['R1'] == 1].index)
Both is super cumbersome. Do you know a easier syntax to achieve this?
For example, if there was something like a idrop function, the second option would be more readably:
df = df.idrop(np.where(df["R1"] == 1)[0])
EDIT:
I had assumed that df = df[df['R1'] != 1]
is less performant then just dropping a row. (Huge Database...)