Skip to content

Commit 0a7d1e9

Browse files
Vibhu-AgarwalPingviinituutti
authored andcommitted
Fixed tuple to List Conversion in Dataframe class (pandas-dev#25089)
1 parent 0e87452 commit 0a7d1e9

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/whatsnew/v0.24.2.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Fixed Regressions
2222

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

25+
- Fixed issue in ``DataFrame`` construction with passing a mixed list of mixed types could segfault. (:issue:`25075`)
26+
2527
.. _whatsnew_0242.enhancements:
2628

2729
Enhancements
@@ -94,4 +96,4 @@ Bug Fixes
9496
Contributors
9597
~~~~~~~~~~~~
9698

97-
.. contributors:: v0.24.1..v0.24.2
99+
.. contributors:: v0.24.1..v0.24.2

pandas/_libs/lib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,7 @@ def to_object_array(rows: object, int min_width=0):
22772277
result = np.empty((n, k), dtype=object)
22782278

22792279
for i in range(n):
2280-
row = <list>input_rows[i]
2280+
row = list(input_rows[i])
22812281

22822282
for j in range(len(row)):
22832283
result[i, j] = row[j]

pandas/tests/frame/test_constructors.py

+7
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,13 @@ def test_constructor_mixed_dict_and_Series(self):
11831183
index=['a', 'b'])
11841184
tm.assert_frame_equal(result, expected)
11851185

1186+
def test_constructor_mixed_type_rows(self):
1187+
# Issue 25075
1188+
data = [[1, 2], (3, 4)]
1189+
result = DataFrame(data)
1190+
expected = DataFrame([[1, 2], [3, 4]])
1191+
tm.assert_frame_equal(result, expected)
1192+
11861193
def test_constructor_tuples(self):
11871194
result = DataFrame({'A': [(1, 2), (3, 4)]})
11881195
expected = DataFrame({'A': Series([(1, 2), (3, 4)])})

0 commit comments

Comments
 (0)