From d1c47b6fb27b7d56cc2339e0fd2c151beac95b36 Mon Sep 17 00:00:00 2001 From: Yuanhao Geng <41546976+GYHHAHA@users.noreply.github.com> Date: Tue, 12 Jul 2022 14:09:30 -0500 Subject: [PATCH 1/3] Update test_sort.py --- pandas/tests/reshape/concat/test_sort.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pandas/tests/reshape/concat/test_sort.py b/pandas/tests/reshape/concat/test_sort.py index a789dc0f8dc83..326abb39a2ca8 100644 --- a/pandas/tests/reshape/concat/test_sort.py +++ b/pandas/tests/reshape/concat/test_sort.py @@ -92,7 +92,22 @@ def test_concat_frame_with_sort_false(self): expected = DataFrame([[2, np.nan], [np.nan, 1]], index=[2, 1], columns=[2, 1]) tm.assert_frame_equal(result, expected) - + + # GH 37937 + df1 = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, index=[1, 2, 3]) + df2 = DataFrame({"c": [7, 8, 9], "d": [10, 11, 12]}, index=[3, 1, 6]) + result = pd.concat([df2, df1], axis=1, sort=False) + expected = DataFrame( + [ + [7.0, 10.0, 3.0, 6.0], + [8.0, 11.0, 1.0, 4.0], + [9.0, 12.0, np.nan, np.nan], + [np.nan, np.nan, 2.0, 5.0], + ], + index=[3, 1, 6, 2], + columns=["c", "d", "a", "b"], + ) + def test_concat_sort_none_warning(self): # GH#41518 df = DataFrame({1: [1, 2], "a": [3, 4]}) From 852e289301ef92252dc7f831b28c93fb4f6a8e67 Mon Sep 17 00:00:00 2001 From: Yuanhao Geng <41546976+GYHHAHA@users.noreply.github.com> Date: Tue, 12 Jul 2022 14:15:45 -0500 Subject: [PATCH 2/3] Update test_sort.py --- pandas/tests/reshape/concat/test_sort.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/reshape/concat/test_sort.py b/pandas/tests/reshape/concat/test_sort.py index 326abb39a2ca8..ca2d56c580ee9 100644 --- a/pandas/tests/reshape/concat/test_sort.py +++ b/pandas/tests/reshape/concat/test_sort.py @@ -92,7 +92,7 @@ def test_concat_frame_with_sort_false(self): expected = DataFrame([[2, np.nan], [np.nan, 1]], index=[2, 1], columns=[2, 1]) tm.assert_frame_equal(result, expected) - + # GH 37937 df1 = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, index=[1, 2, 3]) df2 = DataFrame({"c": [7, 8, 9], "d": [10, 11, 12]}, index=[3, 1, 6]) @@ -107,7 +107,7 @@ def test_concat_frame_with_sort_false(self): index=[3, 1, 6, 2], columns=["c", "d", "a", "b"], ) - + def test_concat_sort_none_warning(self): # GH#41518 df = DataFrame({1: [1, 2], "a": [3, 4]}) From e988e095ec8d8e8a0ac77fa11a75a4eea3e0187c Mon Sep 17 00:00:00 2001 From: Yuanhao Geng <41546976+GYHHAHA@users.noreply.github.com> Date: Tue, 12 Jul 2022 14:20:29 -0500 Subject: [PATCH 3/3] add assert --- pandas/tests/reshape/concat/test_sort.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/reshape/concat/test_sort.py b/pandas/tests/reshape/concat/test_sort.py index ca2d56c580ee9..e83880625f3d6 100644 --- a/pandas/tests/reshape/concat/test_sort.py +++ b/pandas/tests/reshape/concat/test_sort.py @@ -107,6 +107,7 @@ def test_concat_frame_with_sort_false(self): index=[3, 1, 6, 2], columns=["c", "d", "a", "b"], ) + tm.assert_frame_equal(result, expected) def test_concat_sort_none_warning(self): # GH#41518