Reputation: 1048
I am using the below code to draw two kdeplots for a variable:
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)
But I am getting an error as:
ValueError: The number of observations must be larger than the number of variables.
I do not understand why this error is being thrown and how to draw the plots. Can someone please help me regarding this.
Intention is to get something like :
Upvotes: 1
Views: 3792
Reputation: 339250
It seems you want to plot two kde plots of different quantities.
ax = sns.kdeplot(x)
sns.kdeplot(y, ax=ax)
Upvotes: 6