Skip to content

Fixed tuple to List Conversion in Dataframe class #25089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the issue number as a comment

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