Skip to content

Commit a3d5e00

Browse files
TST: .loc dtype change bug (#59101)
* Naive test case for #29707 * Compare frames when testing loc dtype change for #29707 * Update pandas/tests/dtypes/test_dtypes.py --------- Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 2db934e commit a3d5e00

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/dtypes/test_dtypes.py

+12
Original file line numberDiff line numberDiff line change
@@ -1231,3 +1231,15 @@ def test_multi_column_dtype_assignment():
12311231

12321232
df["b"] = 0
12331233
tm.assert_frame_equal(df, expected)
1234+
1235+
1236+
def test_loc_setitem_empty_labels_no_dtype_conversion():
1237+
# GH 29707
1238+
1239+
df = pd.DataFrame({"a": [2, 3]})
1240+
expected = df.copy()
1241+
assert df.a.dtype == "int64"
1242+
df.loc[[]] = 0.1
1243+
1244+
assert df.a.dtype == "int64"
1245+
tm.assert_frame_equal(df, expected)

0 commit comments

Comments
 (0)