I would like to create a boolean column based on the evaluation of another column using pandas. Ideally, I would like to do this with a syntax similar to what I copied, but if this is not possible, I am open to other suggestions.
df is the pandas framework. AggRow is a data column with integers.
So, I have data for AggRow that have a range of values. I can successfully create a new conditionmet column based on one criterion, for example, if I want the condition to be true wherever AggRow is less than or equal to 6001:
conditionmet = df['AggRow'] <= 6001
But if I want the condition to be true, if AggRow is <= 6001 or between 10001 and 10009 inclusive, I am having problems. The following expression gives the conditionmet = True only for the first condition, that is, where AggRow <= 6001, apparently ignoring what I am talking about 10001 and 10009.
conditionmet = ((df['AggRow'] <= 6001) | ((df['AggRow'] >= 10001) & (df['AggRow'] <= 10009)))
How do I make conditionmet = True if AggRow <= 6001 or AggRow and> = 10001 and <= 10009? Again, I would like to get an answer that uses similar syntax, if possible. Thank.
Jimmy source
share