Skip to content

Commit de4406b

Browse files
committed
Changed for compatibility. Python=3.5 needs sort.
1 parent ae19e6c commit de4406b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/core/internals/construction.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas._libs import lib
1111
from pandas._libs.tslibs import IncompatibleFrequency, OutOfBoundsDatetime
1212
from pandas.compat import raise_with_traceback
13+
import pandas.compat as compat
1314

1415
from pandas.core.dtypes.cast import (
1516
construct_1d_arraylike_from_scalar, construct_1d_ndarray_preserving_na,
@@ -284,13 +285,16 @@ def extract_index(data):
284285
have_raw_arrays = False
285286
have_series = False
286287
have_dicts = False
288+
have_ordered = False
287289

288290
for val in data:
289291
if isinstance(val, ABCSeries):
290292
have_series = True
291293
indexes.append(val.index)
292294
elif isinstance(val, dict):
293295
have_dicts = True
296+
if isinstance(val, OrderedDict):
297+
have_ordered = True
294298
indexes.append(list(val.keys()))
295299
elif is_list_like(val) and getattr(val, 'ndim', 1) == 1:
296300
have_raw_arrays = True
@@ -303,7 +307,8 @@ def extract_index(data):
303307
if have_series:
304308
index = _union_indexes(indexes)
305309
elif have_dicts:
306-
index = _union_indexes(indexes, sort=False)
310+
index = _union_indexes(indexes,
311+
sort=not (compat.PY36 or have_ordered))
307312

308313
if have_raw_arrays:
309314
lengths = list(set(raw_lengths))

pandas/tests/frame/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def test_constructor_subclass_dict(self):
484484
dct.update(v.to_dict())
485485
data[k] = dct
486486
frame = DataFrame(data)
487-
tm.assert_frame_equal(self.frame, frame)
487+
tm.assert_frame_equal(self.frame, frame.reindex(self.frame.index))
488488

489489
def test_constructor_dict_block(self):
490490
expected = np.array([[4., 3., 2., 1.]])

0 commit comments

Comments
 (0)