Skip to content

Commit bc80c2a

Browse files
authored
TST: Add test for loc expansion GH13829. (#53812)
Signed-off-by: Liang Yan <[email protected]>
1 parent eac2c00 commit bc80c2a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/frame/indexing/test_setitem.py

+14
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,20 @@ def test_setitem_frame_keep_ea_dtype(self, any_numeric_ea_dtype):
930930
)
931931
tm.assert_frame_equal(df, expected)
932932

933+
def test_loc_expansion_with_timedelta_type(self):
934+
result = DataFrame(columns=list("abc"))
935+
result.loc[0] = {
936+
"a": pd.to_timedelta(5, unit="s"),
937+
"b": pd.to_timedelta(72, unit="s"),
938+
"c": "23",
939+
}
940+
expected = DataFrame(
941+
[[pd.Timedelta("0 days 00:00:05"), pd.Timedelta("0 days 00:01:12"), "23"]],
942+
index=Index([0]),
943+
columns=(["a", "b", "c"]),
944+
)
945+
tm.assert_frame_equal(result, expected)
946+
933947

934948
class TestDataFrameSetItemSlicing:
935949
def test_setitem_slice_position(self):

0 commit comments

Comments
 (0)