Skip to content

Commit

Permalink
Fix deprecation warnings with is_categorical_dtype (#2641)
Browse files Browse the repository at this point in the history
* update pandas calls

* update release notes

* update woodwork

* update woodwork

* update woodwork

* update reqs

* more reqs

* fix isinstance check

---------

Co-authored-by: Nate Parsons <[email protected]>
Co-authored-by: Nate Parsons <[email protected]>
  • Loading branch information
3 people authored Feb 14, 2024
1 parent 7209f8e commit 18e5c41
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Future Release
* Fix dependency issues (:pr:`2644`, :pr:`2656`)
* Add workaround for pandas 2.2.0 bug with nunique and unpin pandas (:pr:`2657`)
* Changes
* Fix deprecation warnings with is_categorical_dtype (:pr:`2641`)
* Documentation Changes
* Update Featuretools logo to display properly in dark mode (:pr:`2632`)
* Testing Changes
Expand All @@ -21,7 +22,6 @@ Future Release
* Fix minimum dependency checker action (:pr:`2664`)
* Fix Slack alert for tests with Woodwork main branch (:pr:`2668`)


Thanks to the following people for contributing to this release:
:user:`gsheni`, :user:`thehomebrewnerd`, :user:`tamargrey`, :user:`LakshmanKishore`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def last_n(df):
#
# Pandas claims that bug is fixed but it still shows up in some
# cases. More investigation needed.
if pdtypes.is_categorical_dtype(frame.index):
if isinstance(frame.index, pd.CategoricalDtype):
categories = pdtypes.CategoricalDtype(
categories=frame.index.categories,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pandas as pd
import pandas.api.types as pdtypes
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime, Ordinal

Expand Down Expand Up @@ -37,8 +36,8 @@ class GreaterThan(TransformPrimitive):

def get_function(self):
def greater_than(val1, val2):
val1_is_categorical = pdtypes.is_categorical_dtype(val1)
val2_is_categorical = pdtypes.is_categorical_dtype(val2)
val1_is_categorical = isinstance(val1.dtype, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2.dtype, pd.CategoricalDtype)
if val1_is_categorical and val2_is_categorical:
if not all(val1.cat.categories == val2.cat.categories):
return val1.where(pd.isnull, np.nan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pandas as pd
import pandas.api.types as pdtypes
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime, Ordinal

Expand Down Expand Up @@ -37,8 +36,8 @@ class GreaterThanEqualTo(TransformPrimitive):

def get_function(self):
def greater_than_equal(val1, val2):
val1_is_categorical = pdtypes.is_categorical_dtype(val1)
val2_is_categorical = pdtypes.is_categorical_dtype(val2)
val1_is_categorical = isinstance(val1.dtype, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2.dtype, pd.CategoricalDtype)
if val1_is_categorical and val2_is_categorical:
if not all(val1.cat.categories == val2.cat.categories):
return val1.where(pd.isnull, np.nan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pandas as pd
import pandas.api.types as pdtypes
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime, Ordinal

Expand Down Expand Up @@ -37,8 +36,8 @@ class LessThan(TransformPrimitive):

def get_function(self):
def less_than(val1, val2):
val1_is_categorical = pdtypes.is_categorical_dtype(val1)
val2_is_categorical = pdtypes.is_categorical_dtype(val2)
val1_is_categorical = isinstance(val1.dtype, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2.dtype, pd.CategoricalDtype)
if val1_is_categorical and val2_is_categorical:
if not all(val1.cat.categories == val2.cat.categories):
return val1.where(pd.isnull, np.nan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pandas as pd
import pandas.api.types as pdtypes
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import BooleanNullable, Datetime, Ordinal

Expand Down Expand Up @@ -37,8 +36,8 @@ class LessThanEqualTo(TransformPrimitive):

def get_function(self):
def less_than_equal(val1, val2):
val1_is_categorical = pdtypes.is_categorical_dtype(val1)
val2_is_categorical = pdtypes.is_categorical_dtype(val2)
val1_is_categorical = isinstance(val1.dtype, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2.dtype, pd.CategoricalDtype)
if val1_is_categorical and val2_is_categorical:
if not all(val1.cat.categories == val2.cat.categories):
return val1.where(pd.isnull, np.nan)
Expand Down

0 comments on commit 18e5c41

Please sign in to comment.