How to Use Two Columns in an Apply Lambda Function

Python

 1|  df[new_col] = df.apply(lambda x: 1 if x.col1 > x.col2 else 0, axis=1)
Did you find this snippet useful?

Sign up for free to to add this to your code library