My exercise 3’s solution is wrong. It notices that I found fewer “Risky” loan than actual number. But I see my condition is right. Anyone can help spot what mistake I made?
GRADED CELL: exercise 3
START CODE HERE
create the column “DebtToIncome”
df[“DebtToIncome”] = df[“Amount”]/df[“IncomeTotal”]
create a new column “IsRisky” that is True if the loan is risky
df[“IsRisky”] = (df[“EmploymentDurationCurrentEmployer”].isin([“TrialPeriod”, “Upto1Year”])) & (df[“DebtToIncome”]>=0.35)
calculate the proportion of risky loans
risky_proportion = len(df[df[“IsRisky”] == True])/len(df)
calculate the mean interest rate of the risky loans
mean_interest_risky = df[df[“IsRisky”] == True][“Interest”].mean()
calculate the mean interest rate of the non-risky loans
mean_interest_non_risky = df[df[“IsRisky”] == False][“Interest”].mean()