I have the following code.
import pandas as pd
data = {'income_bracket':['<=50k', '<=75k', '<=125k', '>1(25k']}
df = pd.DataFrame(data)
def label_fix(label):
if df['income_bracket']== '<=50K':
return 0
else:
return 1
df['income_bracket']=df['income_bracket'].apply(label_fix)
When I run the code, I get the following error.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I would really appreciate any help here. Thanks