Pandas > Select rows using condition

Name
Code
Output
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 3)), columns=['C1','C2','C3'])
print ("dataframe")
print (dataframe)
# single contition
dataframe2 = dataframe.loc[dataframe['C1'] > 50]
print ("dataframe selected rows")
print (dataframe2)
# multiple conditions
dataframe3 = dataframe.loc[(dataframe['C1'] > 20) & (dataframe['C1'] < 50)]
print ("dataframe selected rows")
print (dataframe3)
dataframe
   C1  C2  C3
0  24  55  55
1  84  97  32
2  65  15  83
3  11  31  95
4  41  96  70
dataframe selected rows
   C1  C2  C3
1  84  97  32
2  65  15  83
dataframe selected rows
   C1  C2  C3
0  24  55  55
4  41  96  70