logical or on list of pandas masks
Question: I have a list of boolean masks obtained by applying different search criteria
to a dataframe. Here is an example list containing 4 masks:

    
    
    mask_list = [mask1, mask2, mask3, mask4]
    

I would like to find the logical or of all of the masks in the list. In other
words,

    
    
    or_mask = mask_list[0] | mask_list[1] | mask_list[2] | mask_list[3]
    

Is there a compact way to accomplish this for a list containing an arbitrary
number of masks? I understand that I can write a for loop as below, but is
there a shorter, more pythonic way to do this?

    
    
    for i in range(len(mask_list)):
        if i == 0:
            temp_mask_or = mask_list[i]
        else:
            temp_mask_or = temp_mask_or | mask_list[i]
    


Answer: You can use reduce:

`or_(x,y)` means `x|y` so this will work:

    
    
    from operator import or_
    or_mask = reduce(or_,mask_list)
    

Edit: As suggested by JoeCondron, instead of `operator.or_` you could use
`numpy.logical_or` which gives the same result but is faster.

