Skip to content

Commit b044e04

Browse files
Adding test case for concat OrderedDict and updating . pandas-dev#21510
1 parent f9d105e commit b044e04

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

doc/source/whatsnew/v0.23.2.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,4 +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-
-
86+
- Bug in :class:`_Concatenator` should not sort Ordered Dictionaries (:issue:21510`)
87+
-

pandas/tests/reshape/test_concat.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections import OrderedDict
12
from warnings import catch_warnings
23
from itertools import combinations, product
34

@@ -1294,6 +1295,16 @@ def test_concat_rename_index(self):
12941295
tm.assert_frame_equal(result, exp)
12951296
assert result.index.names == exp.index.names
12961297

1298+
def test_concat_with_ordered_dict(self):
1299+
# 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
1307+
12971308
def test_crossed_dtypes_weird_corner(self):
12981309
columns = ['A', 'B', 'C', 'D']
12991310
df1 = DataFrame({'A': np.array([1, 2, 3, 4], dtype='f8'),

0 commit comments

Comments
 (0)