Pandas has a DataFrame method, query()
, that lets you filter out subsets of data using a logical expression query. Since the expression is a string, it reads a little more naturally than subsetting dataframes using nested brackets. The expression is evaluated in a columnar fashion.