0

enter image description here

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.

Crown716
  • 115
  • 10
Tarun
  • 1

1 Answers1

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

enter image description here

df['label'] = df["Taxable.Income"].apply(lambda x : "good" if x >30000 else " risky")
df

output:

enter image description here

FoCDoT
  • 63
  • 5