I'm trying to combine these two parts as an AND statement.
dataframe = df.loc[~(df['Name'] < -1000)]
dataframe = df.loc[~(df['Name'] > 1000)]
I want it to do something like this:
dataframe = df.loc[~(df['Name'] < -1000)] & df.loc[~(df['Name'] > 1000)]
I have tried using & and AND, and both returned errors, need help.
CodePudding user response:
Try something like this, you don’t need to use .loc
dataframe = df[~(df['Name'] < -1000) & ~(df['Name'] > 1000)]
CodePudding user response:
How about removing the ~
dataframe = df[df['Name'].between(-1000, 1000)]