Skip to content

Instantly share code, notes, and snippets.

@mwaskom
Last active April 18, 2025 07:22
Show Gist options
  • Save mwaskom/de44147ed2974457ad6372750bbe5751 to your computer and use it in GitHub Desktop.
Save mwaskom/de44147ed2974457ad6372750bbe5751 to your computer and use it in GitHub Desktop.
A guide to replacing the deprecated `seaborn.distplot` function.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hash-numpy
Copy link

Hi All, I am facing below errors while using seaborn displot and hisplot: Please help me in resolving the issue. Note: Same error with sns.histplot(tips["total_bill"])

Code: import seaborn as sns tips = sns.load_dataset('tips') sns.displot(tips["total_bill"])

Errors C:\Users\xxx\PycharmProjects\HelloWorld\venv\Lib\site-packages\seaborn_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead if pd.api.types.is_categorical_dtype(vector): C:\Users\xxx\PycharmProjects\HelloWorld\venv\Lib\site-packages\seaborn_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead. with pd.option_context('mode.use_inf_as_na', True):

@swapnak1512
The messages you're seeing are warnings, not errors, so your plot should still render.
suppress the warnings in your scripts.
import warnings
warnings.filterwarnings("ignore")

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset('tips')
sns.displot(tips["total_bill"])
plt.show()

i know this is late but this answer could help somone else having the same kind of warnings
Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment