Skip to content

Commit c711be0

Browse files
authored
TST: avoid sort when concat int-index Dataframes with sort=False (#47685)
* Update test_sort.py * Update test_sort.py * add assert
1 parent 74f4e81 commit c711be0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/reshape/concat/test_sort.py

+16
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ def test_concat_frame_with_sort_false(self):
9393

9494
tm.assert_frame_equal(result, expected)
9595

96+
# GH 37937
97+
df1 = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, index=[1, 2, 3])
98+
df2 = DataFrame({"c": [7, 8, 9], "d": [10, 11, 12]}, index=[3, 1, 6])
99+
result = pd.concat([df2, df1], axis=1, sort=False)
100+
expected = DataFrame(
101+
[
102+
[7.0, 10.0, 3.0, 6.0],
103+
[8.0, 11.0, 1.0, 4.0],
104+
[9.0, 12.0, np.nan, np.nan],
105+
[np.nan, np.nan, 2.0, 5.0],
106+
],
107+
index=[3, 1, 6, 2],
108+
columns=["c", "d", "a", "b"],
109+
)
110+
tm.assert_frame_equal(result, expected)
111+
96112
def test_concat_sort_none_warning(self):
97113
# GH#41518
98114
df = DataFrame({1: [1, 2], "a": [3, 4]})

0 commit comments

Comments
 (0)