Only B and D values are to be decoded as 0; rest of the values would be decoded as 1.
A set of values are decoded as 0 and rest of the values are decoded as 1; may be a binary decoding.
CodePudding user response:
IIUC, you can use:
df['pulse'] = (~df['fault_code'].isin(['B', 'D'])).astype(int)
or taking advantage of boolean -> int equivalence:
df['pulse'] = df['fault_code'].isin(['B', 'D']).rsub(1)
output:
no output as no text data was provided