Pandas row filtering: Using df.loc with a lambda expression

Pandas row filtering: Using df.loc with a lambda expression

To filter a Python Pandas data frame by rows, use the same syntax and rules as for series:

df.loc[ lambda df_: df_['x'] > df_['w'] ]

The lambda still returns a boolean series. The expression can use any column from the data frame.

Tomorrow: How Pandas 3 improves on this.