Skip to content

Commit 3034cfb

Browse files
authored
TST: Nan must not be converted to string using .loc (#45695)
* TST: Nan must not be converted to string Closes #28403 * TST: Add test specific to the issue #28403 * TST: Parametrize multiple inputs change nan loc
1 parent 5c757e9 commit 3034cfb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/indexing/test_loc.py

+16
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@
4343
from pandas.tests.indexing.common import Base
4444

4545

46+
@pytest.mark.parametrize(
47+
"series, new_serie, expected_ser",
48+
[
49+
[[np.nan, np.nan, "b"], ["a", np.nan, np.nan], [False, True, True]],
50+
[[np.nan, "b"], ["a", np.nan], [False, True]],
51+
],
52+
)
53+
def test_not_change_nan_loc(series, new_serie, expected_ser):
54+
# GH 28403
55+
df = DataFrame({"A": series})
56+
df["A"].loc[:] = new_serie
57+
expected = DataFrame({"A": expected_ser})
58+
tm.assert_frame_equal(df.isna(), expected)
59+
tm.assert_frame_equal(df.notna(), ~expected)
60+
61+
4662
class TestLoc(Base):
4763
def test_loc_getitem_int(self):
4864

0 commit comments

Comments
 (0)