From 3c2a3ce0f27a33a52f6fe6fadae272d8410a2e4e Mon Sep 17 00:00:00 2001 From: jackgoldsmith4 Date: Sun, 12 Jun 2022 19:32:01 +0000 Subject: [PATCH 1/3] add test --- pandas/tests/dtypes/test_dtypes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index aef61045179ef..bd63cfd91b38b 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -1140,3 +1140,14 @@ def test_compare_complex_dtypes(): with pytest.raises(TypeError, match=msg): df.lt(df.astype(object)) + +def test_multi_column_dtype_assignment(): + # GH #27583 + df = pd.DataFrame({"a": [0.0], "b": 0.0}) + expected = pd.DataFrame({"a": 0, "b": 0}) + + df[["a", "b"]] = 0 + tm.assert_frame_equal(df, expected) + + df["b"] = 0 + tm.assert_frame_equal(df, expected) From b7372fbc2b8ccda64f3bcc5e8a7105eae574444a Mon Sep 17 00:00:00 2001 From: jackgoldsmith4 Date: Sun, 12 Jun 2022 19:32:53 +0000 Subject: [PATCH 2/3] add blank line --- pandas/tests/dtypes/test_dtypes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index bd63cfd91b38b..b72d97e713d6e 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -1141,6 +1141,7 @@ def test_compare_complex_dtypes(): with pytest.raises(TypeError, match=msg): df.lt(df.astype(object)) + def test_multi_column_dtype_assignment(): # GH #27583 df = pd.DataFrame({"a": [0.0], "b": 0.0}) From 180d0b81155107d36277fe25a0e040082a0d8926 Mon Sep 17 00:00:00 2001 From: jackgoldsmith4 Date: Sun, 12 Jun 2022 16:51:24 -0400 Subject: [PATCH 3/3] fix --- pandas/tests/dtypes/test_dtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index b72d97e713d6e..e127fe27b6209 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -1145,7 +1145,7 @@ def test_compare_complex_dtypes(): def test_multi_column_dtype_assignment(): # GH #27583 df = pd.DataFrame({"a": [0.0], "b": 0.0}) - expected = pd.DataFrame({"a": 0, "b": 0}) + expected = pd.DataFrame({"a": [0], "b": 0}) df[["a", "b"]] = 0 tm.assert_frame_equal(df, expected)