From 06af6c21bd7bd9ee3ca11b9de70a3a44a28d9bad Mon Sep 17 00:00:00 2001 From: Liang Yan Date: Fri, 24 Mar 2023 09:46:30 +0800 Subject: [PATCH] DataFrame transform with fillna test GH#26840 Signed-off-by: Liang Yan --- pandas/tests/groupby/transform/test_transform.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandas/tests/groupby/transform/test_transform.py b/pandas/tests/groupby/transform/test_transform.py index d7dc2d8937467..c1201c33123ab 100644 --- a/pandas/tests/groupby/transform/test_transform.py +++ b/pandas/tests/groupby/transform/test_transform.py @@ -361,6 +361,20 @@ def test_dispatch_transform(tsframe): tm.assert_frame_equal(filled, expected) +def test_transform_fillna_null(): + df = DataFrame( + dict( + price=[10, 10, 20, 20, 30, 30], + color=[10, 10, 20, 20, 30, 30], + cost=(100, 200, 300, 400, 500, 600), + ) + ) + with pytest.raises(ValueError, match="Must specify a fill 'value' or 'method'"): + df.groupby(["price"]).transform("fillna") + with pytest.raises(ValueError, match="Must specify a fill 'value' or 'method'"): + df.groupby(["price"]).fillna() + + def test_transform_transformation_func(transformation_func): # GH 30918 df = DataFrame(