I am learning Pandas dataframes for a project and having trouble understanding some of the operators and how I can use them. In one case, I have one dataframe for production data and another for targets. I can get the items in the production data that met the targets and those that didn't using:
good = prod['A'][prod['A'] >= target['A']] bad = prod['A'][prod['A'] < target['A']] and it works well. But in some cases, I have an upper and lower target, which is where I am getting stuck. I need to find the values that are above the upper target, the values below the lower target and the values that were in between and get 3 separate dataframes. I tried what seemed obvious working with normal lists:
aboveTargetA = prod['A'][prod['A'] >= targetA['A']] belowTargetB = prod['A'][prod['A'] <= targetB['A']] betweenTargets = prod[[col for index, col in df.iterrows() if col not in aboveTargetA and col not in belowTargetB]] I'm not sure how I should be doing it with these dataframes and generators as I have never worked with them before. Can anyone point me in the right direction for the comparisons?