Skip to content

Commit a6f5534

Browse files
committed
BUG: DataFrame constructor regression with dict of tuples close #1491
1 parent 3968707 commit a6f5534

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4604,7 +4604,7 @@ def extract_index(data):
46044604
elif isinstance(v, dict):
46054605
have_dicts = True
46064606
indexes.append(v.keys())
4607-
elif isinstance(v, (list, np.ndarray)):
4607+
elif isinstance(v, (list, tuple, np.ndarray)):
46084608
have_raw_arrays = True
46094609
raw_lengths.append(len(v))
46104610

pandas/tests/test_frame.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,14 @@ def test_constructor_dict_dont_upcast(self):
15791579
dm = DataFrame([[1,2],['a','b']], index=[1,2], columns=[1,2])
15801580
self.assert_(isinstance(dm[1][1], int))
15811581

1582+
def test_constructor_dict_of_tuples(self):
1583+
# GH #1491
1584+
data = {'a': (1, 2, 3), 'b': (4, 5, 6)}
1585+
1586+
result = DataFrame(data)
1587+
expected = DataFrame(dict((k, list(v)) for k, v in data.iteritems()))
1588+
assert_frame_equal(result, expected)
1589+
15821590
def test_constructor_ndarray(self):
15831591
mat = np.zeros((2, 3), dtype=float)
15841592

0 commit comments

Comments
 (0)