I need to apply a single condition to 3 columns of a dataframe and change value of 4th without using or statement .
I can do with np.where but if the no of columns is big it's going to take a lot of time
import pandas as pd
import numpy as np
df = pd.DataFrame({'a':[1,2,3,4],'b':[1,3,6,7],'c':[4,6,4,1], 'd':['p','f','p','u'],'e':['a','a','b','c']})
df['d'] = np.where(df.a > 4 | df.b > 4 | df.c > 4 , 'p',df['d'])
df = pd.DataFrame({'a':[1,2,3,4,5],'b':[1,3,6,7],'c':[4,6,4,1], 'd':['p','f','p','f']})
df['d']=np.where(df.a > 4 | df.b > 4 | df.c > 4 , 'p','f')
I need someway of implementing same condition > , < to list of columns without using or for each.