python - Dataframe Boolean Logic Index Match -
i have created pandas data frame , filter data based on boolean logic. i'd closer excels' index match function simple filtering. have researched lot of other threads. when apply filter, data frame returns 0 true values. why 0 true values being returned when have been flexible logic? and; if introduced 5th column, column 'd' , random.randomint(100-1000,100) , logic use conditionally find maximum values column d ? i.e. can force data frame return highest true values column, in event multiple true values returned? advice appreciated. thank in advance. import pandas pd df = pd.dataframe({ 'step': [1,1,1,1,1,1,2,2,2,2,2,2], 'a': [4,5,6,7,4,5,6,7,4,5,6,7], 'b': [10,20,30,40,10,20,30,40,10,20,30,40], 'c': [0,0.5,1,1.5,2,2.5,0,0.5,1,1.5,2.0,2.5] }) columns = ['step','a','b','c'] df=df[columns] new_df=df[(df.step == 1) & (df.a == 4|5|6|7) & (df.b == 10|20|30|40)] new_df ...