Skip to content

Commit 648e6bf

Browse files
committed
Fix len one list dataframe constructor bug for datetime (pandas-dev#43041)
* Fix len one list dataframe constructor bug for datetime * Move whatsnew Co-authored-by: Jeff Reback <[email protected]> (cherry picked from commit f5d1cac)
1 parent 9ea4eeb commit 648e6bf

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

doc/source/whatsnew/v1.3.3.rst

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ including other versions of pandas.
1414

1515
Fixed regressions
1616
~~~~~~~~~~~~~~~~~
17+
- Fixed regression in :class:`DataFrame` constructor failing to broadcast for defined :class:`Index` and len one list of :class:`Timestamp` (:issue:`42810`)
18+
- Performance regression in :meth:`core.window.ewm.ExponentialMovingWindow.mean` (:issue:`42333`)
1719
-
1820
-
1921

pandas/core/construction.py

-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ def sanitize_array(
552552
subarr = subarr.astype(dtype, copy=copy)
553553
elif copy:
554554
subarr = subarr.copy()
555-
return subarr
556555

557556
else:
558557
if isinstance(data, (set, frozenset)):

pandas/tests/frame/test_constructors.py

+15
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,21 @@ def test_constructor_unequal_length_nested_list_column(self):
12861286
with pytest.raises(ValueError, match=msg):
12871287
DataFrame([[1, 2, 3, 4], [4, 5, 6, 7]], columns=arrays)
12881288

1289+
@pytest.mark.parametrize(
1290+
"data",
1291+
[
1292+
[[Timestamp("2021-01-01")]],
1293+
[{"x": Timestamp("2021-01-01")}],
1294+
{"x": [Timestamp("2021-01-01")]},
1295+
{"x": Timestamp("2021-01-01")},
1296+
],
1297+
)
1298+
def test_constructor_one_element_data_list(self, data):
1299+
# GH#42810
1300+
result = DataFrame(data, index=[0, 1, 2], columns=["x"])
1301+
expected = DataFrame({"x": [Timestamp("2021-01-01")] * 3})
1302+
tm.assert_frame_equal(result, expected)
1303+
12891304
def test_constructor_sequence_like(self):
12901305
# GH 3783
12911306
# collections.Sequence like

0 commit comments

Comments
 (0)