Use numpy.where and chain conditions with & for bitwise AND:
Solution if exist column columnc:
def testfunc(df):
m1 = df['columna'] == 123
m2 = df['columnb'] == 456
df['columnc']= np.where(m1 & m2, 0, df['columnc'])
return df
If not exist is necessary define both values like 0 and 10:
def testfunc(df):
m1 = df['columna'] == 123
m2 = df['columnb'] == 456
df['columnc']= np.where(m1 & m2, 0, 10)
return df
Sample:
df = pd.DataFrame({
'columna':[123,123,4,5],
'columnb':[456,8,456,4],
'columnc':[1,3,5,7],
})
print (df)
columna columnb columnc
0 123 456 1
1 123 8 3
2 4 456 5
3 5 4 7
def testfunc(df):
m1 = df['columna'] == 123
m2 = df['columnb'] == 456
df['columnc']= np.where(m1 & m2, 0, df['columnc'])
return df
df1 = testfunc(df)
print (df1)
columna columnb columnc
0 123 456 0
1 123 8 3
2 4 456 5
3 5 4 7
def testfunc(df):
m1 = df['columna'] == 123
m2 = df['columnb'] == 456
df['columnc']= np.where(m1 & m2, 0, 10)
return df
df1 = testfunc(df)
print (df1)
columna columnb columnc
0 123 456 0
1 123 8 10
2 4 456 10
3 5 4 10
columnc?