SyntaxFix
Write A Post
Hire A Developer
Questions
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