spacepaste

  1.  
  2. df['other'] = np.where((df["k1 [1]"].isnull() & df["k1 [2]"].isnull() & df["k1 [3]"].isnull() & df["k1 [4]"].isnull() & df["k1 [5]"].isnull()) == True, 0, 1)
  3. columns = (1, 2, 3, 4, 5)
  4. df_columns = (lambda x: df["k1 [{}]".format(x)] for x in columns)
  5. df['other'] = np.where(functools.reduce(operators.and_, lambda x: x.isnull() for x in df_columns) == True, 0, 1)
  6. df['other'] = np.where(functools.reduce(operators.and_, lambda x: x.issomethingelse() for x in df_columns) == True, 0, 1)
  7. # ---
  8. column_names = tuple(lambda x: "k1 [{}]".format(x) for x in columns)
  9. df['other'] = np.where(functools.reduce(operators.and_, df[column_names]) == True, 0, 1)
  10.