Skip to content

Commit

Permalink
TST: .loc dtype change bug (#59101)
Browse files Browse the repository at this point in the history
* 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 <10647082+mroeschke@users.noreply.github.com>
  • Loading branch information
MovsisyanM and mroeschke committed Jun 25, 2024
1 parent 2db934e commit a3d5e00
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,3 +1231,15 @@ def test_multi_column_dtype_assignment():

df["b"] = 0
tm.assert_frame_equal(df, expected)


def test_loc_setitem_empty_labels_no_dtype_conversion():
# GH 29707

df = pd.DataFrame({"a": [2, 3]})
expected = df.copy()
assert df.a.dtype == "int64"
df.loc[[]] = 0.1

assert df.a.dtype == "int64"
tm.assert_frame_equal(df, expected)

0 comments on commit a3d5e00

Please sign in to comment.