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 4 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
11 changes: 5 additions & 6 deletions doc/source/whatsnew/v0.24.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ Fixed Regressions

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

- Fixed regression in :meth:`DataFrame.__init__` where mixed type of rows generated `Segmentation fault` (:issue:`25075`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed issue in DataFrame construction with passing a mixed list of mixed types could segfault.


.. _whatsnew_0242.enhancements:

Enhancements
^^^^^^^^^^^^

-
-
- The DataFrame class supports list as well as tuples in the ndarray, which previously raised `TypeError`
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not needed


.. _whatsnew_0242.bug_fixes:

Expand All @@ -37,9 +38,7 @@ Bug Fixes

**Conversion**

-
-
-
- Fixed bug in :meth:`lib.pyx` where `tuple` to `list` conversion failed (:issue:`25089`)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not needed


**Indexing**

Expand Down Expand Up @@ -94,4 +93,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):
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)
data2 = [[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.

you can inline data2 to the constructor

expected = DataFrame(data2)
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