Skip to content

Commit 3a0c265

Browse files
author
Chang She
committed
BUG: ensure axes are Index objects in _arrays_to_mgr
1 parent ab0c629 commit 3a0c265

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5006,7 +5006,7 @@ def _arrays_to_mgr(arrays, arr_names, index, columns, dtype=None):
50065006
arrays = _homogenize(arrays, index, dtype)
50075007

50085008
# from BlockManager perspective
5009-
axes = [columns, index]
5009+
axes = [_ensure_index(columns), _ensure_index(index)]
50105010

50115011
# segregates dtypes and forms blocks matching to columns
50125012
blocks = form_blocks(arrays, arr_names, axes)

pandas/tests/test_frame.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,13 @@ def test_constructor_from_items(self):
22732273
assert_frame_equal(recons, self.mixed_frame)
22742274
self.assert_(isinstance(recons['foo'][0], tuple))
22752275

2276+
rs = DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6])],
2277+
orient='index', columns=['one', 'two', 'three'])
2278+
xp = DataFrame([[1, 2, 3], [4, 5, 6]], index=['A', 'B'],
2279+
columns=['one', 'two', 'three'])
2280+
assert_frame_equal(rs, xp)
2281+
2282+
22762283
def test_constructor_mix_series_nonseries(self):
22772284
df = DataFrame({'A' : self.frame['A'],
22782285
'B' : list(self.frame['B'])}, columns=['A', 'B'])

0 commit comments

Comments
 (0)