Skip to content

BUG: Grouper.cov emits warning unlike DataFrame.cov #27570

Closed
@ghost

Description

Like #27470, another case where Grouper and DataFrame provide essentially the same method but diverge in behavior.

import pandas as pd

df=pd.DataFrame(dict(a=[0,4,8],b=[2,7,12],c=[3,9,11]))
g=df.groupby([0,1,1])

# single row frame silently emits NaNs
df.iloc[[0]].cov()

# single row group emits multiple warnings
g.cov()
RuntimeWarning: Degrees of freedom <= 0 for slice 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Numeric OperationsArithmetic, Comparison, and Logical operationsWarningsWarnings that appear or should be added to pandas

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions