I am using apply function to process name1 column. I can pass in a fix value like 8 into the function but I wish to use the value (num_of_bit) from each row to process name1 column. When I use the code as below, I will get the error. I understand why I got this error but I do not know how to achieve what I want.
def signedProcessing(input,num_of_bit):
if input < (2**num_of_bit)/2:
input += 256
return input
out_df.loc[out_df['range_type'] == "SIGNED", [name1]] = out_df[out_df['range_type']=="SIGNED"][name1].apply(signedProcessing,num_of_bit=out_df[out_df['range_type'] == "SIGNED"]['num_of_bit'])
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
pd.Series.whereinstead of applying.