Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation Warning from pandas #198

Closed
EpigeneMax opened this issue Dec 18, 2023 · 4 comments · Fixed by #199
Closed

Deprecation Warning from pandas #198

EpigeneMax opened this issue Dec 18, 2023 · 4 comments · Fixed by #199

Comments

@EpigeneMax
Copy link
Contributor

patsy uses functions from pandas that are deprecated:

patsy/util.py:672: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  return _pandas_is_categorical_dtype(dt)

I'll take a look and try to make a PR for this.

EpigeneMax added a commit to EpigeneMax/patsy that referenced this issue Dec 18, 2023
@lesteve
Copy link

lesteve commented Jan 2, 2024

It does not look like this issue has gone completely gone away somehow. We see something similar with patsy 0.5.5 inside the scikit-learn CI where we turn warnings into errors for our gallery examples.

I have to say I don't fully follow the logic of #199, maybe I post more comments in the PR about my questions ... in our case it made it slightly worse since the warning is at patsy import time rather than only when you use patsy.util.is_pandas_categorical and it seems like we were only using basic seaborn functionality which did not need patsy.util.is_pandas_categorical.

To reproduce (pandas >= 2.1.0 which is the version that deprecated is_categorical_dtype see this):

PYTHONWARNINGS=error::DeprecationWarning \
    python -c 'import patsy.util; patsy.util.safe_is_pandas_categorical_dtype(int)'

With patsy 0.5.5 you get the error during patsy import, with patsy 0.5.4 you get the warning when calling the patsy.util.safe_is_pandas_categorical.

@lesteve
Copy link

lesteve commented Jan 2, 2024

To make things a bit more complicated, one thing I noticed is that pandas may raise a DeprecationWarning or a FutureWarning depending on the pandas version. Apparently it was a FutureWarning from 2.1.0 until 2.1.3 and is now a DeprecationWarning in 2.1.4.

Context: pandas-dev/pandas#54970 and pandas-dev/pandas#56377.

EpigeneMax added a commit to EpigeneMax/patsy that referenced this issue Jan 3, 2024
@EpigeneMax
Copy link
Contributor Author

Thanks for reporting this, @lesteve.

The patch in #199 indeed moves the warning at import time, and only catches FutureWarning, not DeprecationWarning. With #203 I see no warning with pandas 2.1.4.

@matthewwardrop
Copy link
Collaborator

I noted that as well, but assumed your patch was about making things work when this functionality is eventually removed, and less about suppressing the warnings themselves.... but I can totally see why you'd want to remove those warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants