-1

I'm trying to plot data based on values in two to three other columns. The below code works if I take out & df[df.Age > 50]. Is there a way to adjust the code to work? Thank you!

plt.figure(figsize = (15, 5))
plt.title(f"KDE Plot:", fontsize = 30, fontweight = 'bold')
ax = sns.kdeplot(
    df[df.OpenedLCInd== 1 ] & df[df.Age > 50]['APlusCreditTier'].dropna(),
    label = 'Opened Letter Check',
    lw = 2,
    legend = True
)
plt.legend = True
ax1 = sns.kdeplot(
    df[df.OpenedLCInd == 0]['APlusCreditTier'].dropna(), 
    label = 'No Open Letter Check', 
    lw = 2, legend = True
)
plt.tight_layout()
0

1 Answer 1

2

Your conditional is wrong in the first kdeplot, it should be:

df[df.OpenedLCInd.eq(1) & df.Age.gt(50)]['APlusCreditTier'].dropna()

or

df[(df.OpenedLCInd== 1) & (df.Age > 50)]['APlusCreditTier'].dropna()

See the pandas docs for more information on subsetting your data.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.