在 python 中使用 seaborn 绘制两个变量的 kdeplots

Draw kdeplots for two variables using seaborn in python

我正在使用下面的代码为一个变量绘制两个 kdeplots:

income_df = attrition_df[['Annual Income','Terminated']]
income_left = income_df.loc[income_df['Terminated'] == 1]
income_stayed = income_df.loc[income_df['Terminated'] == 0]
x = np.array(income_left['Annual Income'].values)
y = np.array(income_stayed['Annual Income'].values)
ax = sns.kdeplot(x,y, shade=True)

但是我收到一个错误:

ValueError: 观测数必须大于变量数。

我不明白为什么会抛出这个错误以及如何绘制绘图。有人可以帮我解决这个问题吗? 目的是得到类似的东西:

您似乎想绘制两个不同数量的 kde 图。

ax = sns.kdeplot(x)
sns.kdeplot(y, ax=ax)