Skip to content

BUG: DataFrameGroupBy.value_counts fails with a TimeGrouper #50486

Closed
@rhshadrach

Description

@rhshadrach
df = pd.DataFrame(
    {
        "Timestamp": [
            1565083561,
            1565083561 + 86400,
            1565083561 + 86500,
            1565083561 + 86400 * 2,
            1565083561 + 86400 * 3,
            1565083561 + 86500 * 3,
            1565083561 + 86400 * 4,
        ],
        "Food": ["apple", "apple", "banana", "banana", "orange", "orange", "pear"],
    }
).drop([3])

df["Datetime"] = to_datetime(df["Timestamp"].apply(lambda t: str(t)), unit="s")
gb = df.groupby(pd.Grouper(freq="1D", key="Datetime"))
print(gb.value_counts())

raises ValueError: operands could not be broadcast together with shapes (5,) (6,) (5,)

Metadata

Metadata

Assignees

Labels

AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffBugGroupby

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions