Skip to content

BUG: Groupby object does not implement len() method #442

@qianduoduo0904

Description

@qianduoduo0904

Describe the bug

Groupby object does not implement len() method.

To Reproduce

To help us to reproduce this bug, please provide information below:

  1. Your Python version
  2. The version of Xorbits you use
  3. Versions of crucial packages, such as numpy, scipy and pandas
  4. Full stack of the error.
  5. Minimized code to reproduce the error.
In [1]: import xorbits.pandas as pd

In [2]: df = pd.DataFrame({'a': ['a', 'b', 'a', 'c'], 'b': [0.1, 0.2, 0.3, 0.4], 'c': ['aa', 'bb', 'cc', 'aa']})

In [3]: grouped = df.groupby('b')

In [4]: len(grouped)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 len(grouped)

File ~/Workspace/xorbits/python/xorbits/core/data.py:267, in DataRef.__len__(self)
    263             raise TypeError(
    264                 f"object with shape {self.data._mars_entity.shape} has no len()"
    265             )
    266 else:
--> 267     raise TypeError(f"object of type '{self.data.data_type}' has no len()")

TypeError: object of type 'DataType.dataframe_groupby' has no len()

Expected behavior

__len__() implementd.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions