Skip to content

Commit 6869e2c

Browse files
Improving test case for orderedDict and whatsnew info. pandas-dev#21510
1 parent eaa7cc0 commit 6869e2c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

doc/source/whatsnew/v0.23.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@ Bug Fixes
8383
**Other**
8484

8585
- Bug in :meth:`Series.nlargest` for signed and unsigned integer dtypes when the minimum value is present (:issue:`21426`)
86-
- Bug in :class:`_Concatenator` should not sort Ordered Dictionaries (:issue:`21510`)
86+
- Bug in :class:`_Concatenator` should maintain dict ordering when :meth:`concat` is called (:issue:`2151`)
8787
-

pandas/tests/reshape/test_concat.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1297,13 +1297,14 @@ def test_concat_rename_index(self):
12971297

12981298
def test_concat_with_ordered_dict(self):
12991299
# GH 21510
1300-
ps = pd.concat(OrderedDict([('First', pd.Series(range(3))),
1301-
('Another', pd.Series(range(4)))]))
1302-
ps_list = list(ps.keys())
1303-
exp_list = [('First', 0), ('First', 1), ('First', 2),
1304-
('Another', 0), ('Another', 1),
1305-
('Another', 2), ('Another', 3)]
1306-
assert ps_list == exp_list
1300+
result = pd.concat(OrderedDict([('First', pd.Series(range(3))),
1301+
('Another', pd.Series(range(4)))]))
1302+
a = pd.Series(range(3), range(3))
1303+
b = pd.Series(range(4), range(4))
1304+
a.index = pd.MultiIndex.from_tuples([('First', v) for v in a.index])
1305+
b.index = pd.MultiIndex.from_tuples([('Another', v) for v in b.index])
1306+
expected = a.append(b)
1307+
tm.assert_series_equal(result, expected)
13071308

13081309
def test_crossed_dtypes_weird_corner(self):
13091310
columns = ['A', 'B', 'C', 'D']

0 commit comments

Comments
 (0)