Pandas: Check If Column Value Is Smaller Than Any Previous Column Value
I want to check if any value of column 'c' is smaller than all previous column values. In my current approach I am using pandas diff(), but it let's me only compare to the previous
Solution 1:
This should work:
df['diff'] = df['c'] < df['c'].cummax()
Output is just as you mentioned:
c diff
01False14False29False37True48True536False
Post a Comment for "Pandas: Check If Column Value Is Smaller Than Any Previous Column Value"