Skip to content

Commit 7c9b0f1

Browse files
committed
pandas-devGH-24196: regression test on sum nan implemented
1 parent 23f74d3 commit 7c9b0f1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/groupby/test_groupby.py

+13
Original file line numberDiff line numberDiff line change
@@ -2970,3 +2970,16 @@ def test_groupby_numeric_only_std_no_result(numeric_only):
29702970
ValueError, match="could not convert string to float: 'bar'"
29712971
):
29722972
dfgb.std(numeric_only=numeric_only)
2973+
2974+
2975+
@pytest.mark.parametrize("bug_var", [1, "a"])
2976+
def test_groupby_sum_on_nan_should_return_nan(bug_var):
2977+
# GH 24196
2978+
df = pd.DataFrame({
2979+
'A': [bug_var, bug_var, bug_var, np.nan]
2980+
})
2981+
dfgb = df.groupby(lambda x: x)
2982+
result = dfgb.sum(min_count=1)
2983+
2984+
expected_df = DataFrame([bug_var, bug_var, bug_var, np.nan], columns=["A"])
2985+
tm.assert_frame_equal(result, expected_df)

0 commit comments

Comments
 (0)