From fc5b3a0d3839212119c148500a59953b89dc5f98 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 17 Dec 2020 12:40:35 +0100 Subject: [PATCH 1/2] ARROW-10951: [Python][CI] Fix nightly pandas builds (pytest monkeypatch issue) --- python/pyarrow/tests/test_pandas.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index 2b5d818d9139..c13ca14caa91 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -3917,7 +3917,12 @@ def test_convert_to_extension_array(monkeypatch): tm.assert_frame_equal(result, df2) # monkeypatch pandas Int64Dtype to *not* have the protocol method - monkeypatch.delattr(pd.core.arrays.integer._IntegerDtype, "__from_arrow__") + if LooseVersion(pd.__version__) < "1.3.0.dev": + monkeypatch.delattr( + pd.core.arrays.integer._IntegerDtype, "__from_arrow__") + else: + monkeypatch.delattr( + pd.core.arrays.integer.NumericDtype, "__from_arrow__") # Int64Dtype has no __from_arrow__ -> use normal conversion result = table.to_pandas() assert len(result._data.blocks) == 1 @@ -3969,10 +3974,12 @@ def test_conversion_extensiontype_to_extensionarray(monkeypatch): # (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__") + elif LooseVersion(pd.__version__) < "1.3.0.dev": + monkeypatch.delattr( + pd.core.arrays.integer._IntegerDtype, "__from_arrow__") else: monkeypatch.delattr( - pd.core.arrays.integer._IntegerDtype, "__from_arrow__", - raising=False) + pd.core.arrays.integer.NumericDtype, "__from_arrow__") result = arr.to_pandas() assert not isinstance(result._data.blocks[0], _int.ExtensionBlock) From b0dd4dbbc8b5f8ca2c89d3f95f002065c249e135 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 21 Dec 2020 09:57:36 +0100 Subject: [PATCH 2/2] workaround in test_mixed_column_names for regression on pandas master --- python/pyarrow/tests/test_pandas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index c13ca14caa91..f4c67a544077 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -416,7 +416,7 @@ def test_mixed_column_names(self): pa.Table.from_pandas(df) expected = df.copy() - expected.columns = df.columns.astype(str) + expected.columns = df.columns.values.astype(str) with pytest.warns(UserWarning): _check_pandas_roundtrip(df, expected=expected, preserve_index=True)