I'm working on a dataframe that needs to create a large amount of flags, depending on multiple conditions. I'm using np.where but now I'm running into this error 
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
For replicability and simplicity, I'm only sharing the part of the code that produces the error together with the columns that are used. Dataframe being used:
     Data  Uniques  day_a1  day_a2  day_a3
0       1        1       3     NaN     NaN
1       2        2      14    15.0     NaN
2       2        1      10    10.0     NaN
3       3        1      10    10.0    10.0
802     2        2      12     NaN    29.0
806     1        1      29     NaN     NaN
Code that generates the error:
df['flag_3.3.3.1.1'] = np.where(
    (
        (df['Data'] == 3) & 
        (df['day_a1'] != 10) & 
        (df['Uniques'] == 3) & #I ran this separately and it was fine
        (df['day_a1'] > 27 or df['day_a1'] < 4).any()),'flag',np.nan)
I seem to still have issues after passying .any() after the or.
 
    