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

Fix deprecation warnings with is_categorical_dtype #2641

Merged
merged 10 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Future Release
* Enhancements
* Fixes
* Changes
* Fix deprecation warnings with is_categorical_dtype (:pr:`2641`)
* Documentation Changes
* Testing Changes
* Update tests for compatibility with new versions of ``holidays`` (:pr:`2636`)
* Update ruff to 0.1.6 and use ruff linter/formatter (:pr:`2639`)
* Update tests for compatibility with new versions of ``holidays`` (:pr:`2636`)
* Update ruff to 0.1.6 and use ruff linter/formatter (:pr:`2639`)

Thanks to the following people for contributing to this release:
:user:`gsheni`, :user:`thehomebrewnerd`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,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, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2, 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, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2, 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, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2, 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, pd.CategoricalDtype)
val2_is_categorical = isinstance(val2, 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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ docs = [
]
dev = [
"ruff >= 0.1.6",
"black[jupyter] >= 23.1.0",
"pre-commit >= 2.20.0",
"featuretools[docs,dask,spark,test]",
]
Expand Down
Loading