Skip to content

group_by produces 'minlength must be positive error' when applied to empty DataFrame #11699

Closed
@Sereger13

Description

@Sereger13

This used to work fine in previous versions but appears to be broken in 0.17.1

The following code:

import pandas as pd
df = pd.DataFrame({'A': [], 'B': []})
gb = df.groupby('A') .size()

Produces this error:

ValueError: minlength must be positive

In v 0.16.2 the same code produced an empty DataFrame. We'd really like to upgrade to 0.17.1 but heavily rely on this functionality so have to hold the upgrade. Checking for empty DataFrame is not going to work for us either as there are too many places where it can actually be empty.

If you can suggest any workaround in the meantime so we could upgrade that would be appreciated.

INSTALLED VERSIONS

commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.18-238.9.1.el5
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US

pandas: 0.16.2
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions