Skip to content

nunique + TimeGrouper error #12352

Closed
Closed
@wavexx

Description

@wavexx

This used to work in the past:

tmp = pd.DataFrame({
        'ID': {pd.Timestamp('2015-06-05 00:00:00'): '0010100903', pd.Timestamp('2015-06-08 00:00:00'): '0010150847'},
        'DATE': {pd.Timestamp('2015-06-05 00:00:00'): '2015-06-05', pd.Timestamp('2015-06-08 00:00:00'): '2015-06-08'}})
tmp.groupby(pd.TimeGrouper('D')).ID.nunique()

but now I get the obscure:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    tmp.groupby(pd.TimeGrouper('D')).ID.nunique()
  File "/usr/lib/python3/dist-packages/pandas/core/groupby.py", line 2697, in nunique
    name=self.name)
  File "/usr/lib/python3/dist-packages/pandas/core/series.py", line 227, in __init__
    data = SingleBlockManager(data, index, fastpath=True)
  File "/usr/lib/python3/dist-packages/pandas/core/internals.py", line 3736, in __init__
    ndim=1, fastpath=True)
  File "/usr/lib/python3/dist-packages/pandas/core/internals.py", line 2454, in make_block
    placement=placement)
  File "/usr/lib/python3/dist-packages/pandas/core/internals.py", line 87, in __init__
    len(self.values), len(self.mgr_locs)))
ValueError: Wrong number of items passed 2, placement implies 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions