callmeanythingyouwant
callmeanythingyouwant

Reputation: 1997

TypeError: distplot() got an unexpected keyword argument 'x' (or 'hue')

I get the error when I try and plot this-

sns.distplot(X_train, x='Age')                   #Age is a feature in X_train

I get a similar error when I try and add the hue parameter in there

sns.distplot(X_train['Age'], hue=y_train)

TypeError: distplot() got an unexpected keyword argument 'hue'

What am I doing wrong? Here is where I am trying out the code from-

https://seaborn.pydata.org/tutorial/distributions.html

Upvotes: 11

Views: 17242

Answers (1)

callmeanythingyouwant
callmeanythingyouwant

Reputation: 1997

If someone comes across this same issue, here's what lead to the confusion. Thanks @user2864740

sns.distplot() is deprecated.

sns.displot() is the new function with hue and x parameters.

If you get this error, update your seaborn version. In cmd -

pip install seaborn --upgrade

From inside a notebook, add an ! before pip

Upvotes: 22

Related Questions