Это то, что вам нужно np.where
с %
The % (modulo) operator yields the remainder from the division of the
first argument by the second
np.where(df.a%2,df.b*2,df.b*3)
Out[1115]: array([12, 21, 16, 27], dtype=int64)
df['c']= np.where(df.a%2,df.b*2,df.b*3)
Уммм, может быть, используется десятичное скрытое двоичное число
(-df.a.map(bin).str[-1].astype(int)+3)*df.b
Out[1125]:
0 12
1 21
2 16
3 27
dtype: int64