Skip to content

[SPARK-35599][PYTHON] Adjust check_exact parameter for older pd.testing #32772

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

Closed
wants to merge 3 commits into from
Closed
Changes from all 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
18 changes: 17 additions & 1 deletion python/pyspark/testing/pandasutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import pandas as pd
from pandas.api.types import is_list_like
from pandas.core.dtypes.common import is_numeric_dtype
from pandas.testing import assert_frame_equal, assert_index_equal, assert_series_equal

from pyspark import pandas as ps
Expand Down Expand Up @@ -81,6 +82,12 @@ def assertPandasEqual(self, left, right, check_exact=True):
else:
kwargs = dict()

if LooseVersion(pd.__version__) < LooseVersion("1.1.1"):
# Due to https://github.com/pandas-dev/pandas/issues/35446
check_exact = check_exact \
and all([is_numeric_dtype(dtype) for dtype in left.dtypes]) \
and all([is_numeric_dtype(dtype) for dtype in right.dtypes])

assert_frame_equal(
left,
right,
Expand All @@ -102,7 +109,11 @@ def assertPandasEqual(self, left, right, check_exact=True):
kwargs = dict(check_freq=False)
else:
kwargs = dict()

if LooseVersion(pd.__version__) < LooseVersion("1.1.1"):
# Due to https://github.com/pandas-dev/pandas/issues/35446
check_exact = check_exact \
and is_numeric_dtype(left.dtype) \
and is_numeric_dtype(right.dtype)
assert_series_equal(
left,
right,
Expand All @@ -119,6 +130,11 @@ def assertPandasEqual(self, left, right, check_exact=True):
raise AssertionError(msg) from e
elif isinstance(left, pd.Index) and isinstance(right, pd.Index):
try:
if LooseVersion(pd.__version__) < LooseVersion("1.1.1"):
# Due to https://github.com/pandas-dev/pandas/issues/35446
check_exact = check_exact \
and is_numeric_dtype(left.dtype) \
and is_numeric_dtype(right.dtype)
assert_index_equal(left, right, check_exact=check_exact)
except AssertionError as e:
msg = (
Expand Down