Skip to content

Commit afac1aa

Browse files
authored
Merge pull request statsmodels#8830 from bashtage/monkey-patch-patsy
MAINT: Monkey deprecated patsy function
2 parents 3e739c2 + a8f0552 commit afac1aa

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

statsmodels/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from statsmodels.compat.patsy import monkey_patch_cat_dtype
2+
13
from statsmodels._version import __version__, __version_tuple__
24

35
__version_info__ = __version_tuple__
46

7+
monkey_patch_cat_dtype()
58

69
debug_warnings = False
710

statsmodels/compat/patsy.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from statsmodels.compat.pandas import PD_LT_2
2+
3+
import pandas as pd
4+
import patsy.util
5+
6+
7+
def _safe_is_pandas_categorical_dtype(dt):
8+
if PD_LT_2:
9+
return pd.api.types.is_categorical_dtype(dt)
10+
return isinstance(dt, pd.CategoricalDtype)
11+
12+
13+
def monkey_patch_cat_dtype():
14+
patsy.util.safe_is_pandas_categorical_dtype = (
15+
_safe_is_pandas_categorical_dtype
16+
)

0 commit comments

Comments
 (0)