Filtering table rows using two conditions

I wanted to filter a column in the hail table based on two conditions.

ex: let’s say ‘AF’ is the column. We wanted to filter the rows whose values are less than 0.01 and also those rows which are having null/missing/NaN values.

We are trying to do this using the below code.
mt.filter(mt[‘AF’] < 0.01 | mt[‘AF’] == NA ) and its throwing an error.
TypeError: unsupported operand type(s) for |: ‘float’ and ‘Float64Expression’

What is the best way to do filtering based on multiple conditions?


mt.filter((mt[‘AF’] < 0.01) | (mt[‘AF’] == NA)) Needed more parens. The precedence of | is higher than < and the or from normal python. This is something we can’t change about python.

Hi John,
Thanks for replying. Now I am getting the below error instead.
NameError: name ‘NA’ is not defined

Is there a way to filter null values in the hail table?


Oh yeah. The null test should be hl.is_missing(mt['AF'])

Thanks again, John. Our issue got resolved.