Skip to content

BUG: DataFrameGroupBy.sum ignores min_count for boolean data type #34051

Closed
@dsaxton

Description

@dsaxton
  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandas.
  • (optional) I have confirmed this bug exists on the master branch of pandas.

Behavior is from master:

import pandas as pd

df = pd.DataFrame({"a": [1, 2], "b": pd.array([True, True])})
df.groupby("a").sum(min_count=2)

gives

      b
a      
1  True
2  True

but expected output is

      b
a      
1  <NA>
2  <NA>

It looks to me like there's an attempt to compute a Cythonized result which fails, after which point the min_count argument is forgotten.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugGroupbyNA - MaskedArraysRelated to pd.NA and nullable extension arraysNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions