From cf6d1d15b99bec25ad8eae309be7c0c3ef202336 Mon Sep 17 00:00:00 2001 From: samukweku Date: Wed, 18 Oct 2023 20:20:38 +1100 Subject: [PATCH] add test for single condition --- pandas/tests/test_case_when.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/test_case_when.py b/pandas/tests/test_case_when.py index 45fd2f238ddc7f..3332c6086c8f8e 100644 --- a/pandas/tests/test_case_when.py +++ b/pandas/tests/test_case_when.py @@ -51,6 +51,15 @@ def test_case_when_raise_error_from_mask(df): case_when(df["a"].eq(1), df) +def test_case_when_single_condition(df): + """ + Test output on a single condition. + """ + result = case_when(df.a.eq(1), 1) + expected = Series([1, np.nan, np.nan]) + tm.assert_series_equal(result, expected) + + def test_case_when_multiple_conditions(df): """ Test output when booleans are derived from a computation