Skip to content

Commit

Permalink
ARROW-8106: [Python] Ensure extension array conversion tests passes w…
Browse files Browse the repository at this point in the history
…ith latest pandas

It's not fixing the underlying issue (ARROW-7857), but at least making sure the test build is green again.

Closes #6614 from jorisvandenbossche/ARROW-8106

Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Wes McKinney <wesm+git@apache.org>
  • Loading branch information
jorisvandenbossche authored and wesm committed Mar 13, 2020
1 parent 963ac4f commit 138ab1e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3622,11 +3622,14 @@ def test_conversion_extensiontype_to_extensionarray(monkeypatch):
arr = pa.ExtensionArray.from_storage(MyCustomIntegerType(), storage)
table = pa.table({'a': arr})

if LooseVersion(pd.__version__) < "0.26.0.dev":
# ensure pandas Int64Dtype has the protocol method (for older pandas)
monkeypatch.setattr(
pd.Int64Dtype, '__from_arrow__', _Int64Dtype__from_arrow__,
raising=False)
# TODO TEMP use our monkeypatched method for all pandas versions because
# latest pandas release / master fails to cast extension type to int64
# type (see ARROW-7857)
# if LooseVersion(pd.__version__) < "0.26.0.dev":
# ensure pandas Int64Dtype has the protocol method (for older pandas)
monkeypatch.setattr(
pd.Int64Dtype, '__from_arrow__', _Int64Dtype__from_arrow__,
raising=False)

# extension type points to Int64Dtype, which knows how to create a
# pandas ExtensionArray
Expand All @@ -3637,9 +3640,11 @@ def test_conversion_extensiontype_to_extensionarray(monkeypatch):

# monkeypatch pandas Int64Dtype to *not* have the protocol method
# (remove the version added above and the actual version for recent pandas)
if LooseVersion(pd.__version__) < "0.26.0.dev":
monkeypatch.delattr(pd.Int64Dtype, "__from_arrow__")
else:
# TODO TEMP see above
# if LooseVersion(pd.__version__) < "0.26.0.dev":
monkeypatch.delattr(pd.Int64Dtype, "__from_arrow__")
# else:
if LooseVersion(pd.__version__) >= "0.26.0.dev":
monkeypatch.delattr(
pd.core.arrays.integer._IntegerDtype, "__from_arrow__",
raising=False)
Expand Down

0 comments on commit 138ab1e

Please sign in to comment.