Hi, in the above picture I have a column named taxable income . I want to add one more column next to it such that the income less than equal to 30000 is labelled as risky and income more than 30000 is labelled as good.
Asked
Active
Viewed 107 times
1 Answers
0
df = pd.DataFrame({"Taxable.Income" : [15000 + random.randint(0,1)*30000 for i in range(500)]}) # creating a sample data frame
data frame looks like this
df['label'] = df["Taxable.Income"].apply(lambda x : "good" if x >30000 else " risky")
df
output:

FoCDoT
- 63
- 5