Skip to content

Commit af839c5

Browse files
committed
FIX: #611 namedtuple breaks to_object_array_tuples
1 parent fb55f3c commit af839c5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/src/inference.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def to_object_array_tuples(list rows):
448448
result = np.empty((n, k), dtype=object)
449449

450450
for i from 0 <= i < n:
451-
row = rows[i]
451+
row = tuple(rows[i]) # upcast any subclasses to tuple
452452

453453
for j from 0 <= j < len(row):
454454
result[i, j] = row[j]

pandas/tests/test_tseries.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,17 @@ def test_unicode(self):
275275
def test_datetime(self):
276276
pass
277277

278+
def test_to_object_array_tuples(self):
279+
r = (5,6)
280+
values = [r]
281+
result = lib.to_object_array_tuples(values)
282+
283+
# make sure record array works
284+
import collections as col
285+
record = col.namedtuple('record', 'x y')
286+
r = record(5,6)
287+
values = [r]
288+
result = lib.to_object_array_tuples(values)
278289

279290
class TestMoments(unittest.TestCase):
280291
pass

0 commit comments

Comments
 (0)