Skip to content

Commit

Permalink
pandas-devGH-24196: regression test on sum nan implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaiwald committed Apr 18, 2023
1 parent 23f74d3 commit 7c9b0f1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2970,3 +2970,16 @@ def test_groupby_numeric_only_std_no_result(numeric_only):
ValueError, match="could not convert string to float: 'bar'"
):
dfgb.std(numeric_only=numeric_only)


@pytest.mark.parametrize("bug_var", [1, "a"])
def test_groupby_sum_on_nan_should_return_nan(bug_var):
# GH 24196
df = pd.DataFrame({
'A': [bug_var, bug_var, bug_var, np.nan]
})
dfgb = df.groupby(lambda x: x)
result = dfgb.sum(min_count=1)

expected_df = DataFrame([bug_var, bug_var, bug_var, np.nan], columns=["A"])
tm.assert_frame_equal(result, expected_df)

0 comments on commit 7c9b0f1

Please sign in to comment.