How to apply conditional logic to a Pandas DataFrame.
See DataFrame shown below,
data desired_output 0 1 False 1 2 Fals
In this specific example, where the DataFrame is only one column, you can write this elegantly as:
df['desired_output'] = df.le(2.5)
le tests whether elements are less than or equal 2.5, similarly lt for less than, gt and ge.
le
lt
gt
ge