Skip to content

Commit

Permalink
Fixed tuple to List Conversion in Dataframe class (#25089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vibhu-Agarwal authored and jreback committed Feb 6, 2019
1 parent e3b0950 commit f04bb2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion doc/source/whatsnew/v0.24.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Fixed Regressions

- Fixed regression in :meth:`DataFrame.all` and :meth:`DataFrame.any` where ``bool_only=True`` was ignored (:issue:`25101`)

- Fixed issue in ``DataFrame`` construction with passing a mixed list of mixed types could segfault. (:issue:`25075`)

.. _whatsnew_0242.enhancements:

Enhancements
Expand Down Expand Up @@ -94,4 +96,4 @@ Bug Fixes
Contributors
~~~~~~~~~~~~

.. contributors:: v0.24.1..v0.24.2
.. contributors:: v0.24.1..v0.24.2
2 changes: 1 addition & 1 deletion pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2277,7 +2277,7 @@ def to_object_array(rows: object, int min_width=0):
result = np.empty((n, k), dtype=object)

for i in range(n):
row = <list>input_rows[i]
row = list(input_rows[i])

for j in range(len(row)):
result[i, j] = row[j]
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,13 @@ def test_constructor_mixed_dict_and_Series(self):
index=['a', 'b'])
tm.assert_frame_equal(result, expected)

def test_constructor_mixed_type_rows(self):
# Issue 25075
data = [[1, 2], (3, 4)]
result = DataFrame(data)
expected = DataFrame([[1, 2], [3, 4]])
tm.assert_frame_equal(result, expected)

def test_constructor_tuples(self):
result = DataFrame({'A': [(1, 2), (3, 4)]})
expected = DataFrame({'A': Series([(1, 2), (3, 4)])})
Expand Down

0 comments on commit f04bb2f

Please sign in to comment.