From b5985f264a47b273fc772e825378713605ee5b26 Mon Sep 17 00:00:00 2001 From: BarkotBeyene Date: Fri, 5 Aug 2022 08:53:28 -0500 Subject: [PATCH 1/3] TST: GH39984 Addition to tests --- pandas/tests/indexes/multi/test_constructors.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandas/tests/indexes/multi/test_constructors.py b/pandas/tests/indexes/multi/test_constructors.py index 7fad59fc6654c..32fcd89255cf4 100644 --- a/pandas/tests/indexes/multi/test_constructors.py +++ b/pandas/tests/indexes/multi/test_constructors.py @@ -6,6 +6,7 @@ import numpy as np import pytest +import pyarrow as pa from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike @@ -647,6 +648,22 @@ def test_from_frame(): result = MultiIndex.from_frame(df) tm.assert_index_equal(expected, result) +def test_from_frame_multiIndex(): + # GH 39984 + df = pd.DataFrame( + { + 'a':pd.Series([1, 2, None], dtype='Int64'), + 'b':pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])) + }) + multi_indexed = pd.MultiIndex.from_frame(df) + expected = pd.MultiIndex.from_arrays( + [ + pd.Series([1, 2, None]).astype('Int64'), + pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])) + ], + names=["a", "b"], + ) + tm.assert_index_equal(multi_indexed, expected) @pytest.mark.parametrize( "non_frame", From 871673f8cb56e8140abde5bb3257b3468eeba3c2 Mon Sep 17 00:00:00 2001 From: BarkotBeyene Date: Wed, 10 Aug 2022 01:14:49 -0500 Subject: [PATCH 2/3] TST: GH39984 Addition to tests --- .../tests/indexes/multi/test_constructors.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pandas/tests/indexes/multi/test_constructors.py b/pandas/tests/indexes/multi/test_constructors.py index 32fcd89255cf4..c6b9ffde4175f 100644 --- a/pandas/tests/indexes/multi/test_constructors.py +++ b/pandas/tests/indexes/multi/test_constructors.py @@ -5,8 +5,8 @@ import itertools import numpy as np -import pytest import pyarrow as pa +import pytest from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike @@ -648,23 +648,26 @@ def test_from_frame(): result = MultiIndex.from_frame(df) tm.assert_index_equal(expected, result) -def test_from_frame_multiIndex(): + +def test_from_frame_missing_values_multiIndex(): # GH 39984 df = pd.DataFrame( { - 'a':pd.Series([1, 2, None], dtype='Int64'), - 'b':pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])) - }) - multi_indexed = pd.MultiIndex.from_frame(df) - expected = pd.MultiIndex.from_arrays( + "a": Series([1, 2, None], dtype="Int64"), + "b": pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])), + } + ) + multi_indexed = MultiIndex.from_frame(df) + expected = MultiIndex.from_arrays( [ - pd.Series([1, 2, None]).astype('Int64'), - pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])) + Series([1, 2, None]).astype("Int64"), + pd.Float64Dtype().__from_arrow__(pa.array([0.2, np.nan, None])), ], names=["a", "b"], ) tm.assert_index_equal(multi_indexed, expected) + @pytest.mark.parametrize( "non_frame", [ From be3b3d973f22ee1280542434d1e32466dc41cdc7 Mon Sep 17 00:00:00 2001 From: BarkotBeyene Date: Thu, 11 Aug 2022 16:39:14 -0500 Subject: [PATCH 3/3] TST: GH39984 Addition to tests --- pandas/tests/indexes/multi/test_constructors.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/tests/indexes/multi/test_constructors.py b/pandas/tests/indexes/multi/test_constructors.py index c6b9ffde4175f..8ef3057c40e90 100644 --- a/pandas/tests/indexes/multi/test_constructors.py +++ b/pandas/tests/indexes/multi/test_constructors.py @@ -8,6 +8,8 @@ import pyarrow as pa import pytest +from pandas.compat import pa_version_under1p01 + from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike import pandas as pd @@ -649,6 +651,7 @@ def test_from_frame(): tm.assert_index_equal(expected, result) +@pytest.mark.skipif(pa_version_under1p01) def test_from_frame_missing_values_multiIndex(): # GH 39984 df = pd.DataFrame(