Skip to content

Implement DataFrameGroupBy, RollingGroupby, ExpandingGroupby #36

Open
@hermian

Description

@hermian

What you were trying to do (and why)

The problem occurs when the apply function is called after applying groupby to the data frame.

What happened (including reproducible example)

Reproducible example

def square(x):
    return x * x

df = pd.DataFrame({'A': 'a a b'.split(),
                   'B': [1,2,3],
                   'C': [4,6,5]})

df.groupby('A')[['B', 'C']].mapply(square)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/workspace/git/screener/mmt/kospi_naver_db.py in <cell line: 1>()
----> 1 df.groupby('A', group_keys=True)[['B', 'C']].mapply(square)

/opt/homebrew/Caskroom/miniconda/base/envs/py38/lib/python3.8/site-packages/mapply/mapply.py in mapply(df_or_series, func, axis, n_workers, chunk_size, max_chunks_per_worker, progressbar, args, **kwargs)
     95 
     96     n_chunks = _choose_n_chunks(
---> 97         df_or_series.shape,
     98         opposite_axis,
     99         n_workers,

/opt/homebrew/Caskroom/miniconda/base/envs/py38/lib/python3.8/site-packages/pandas/core/groupby/groupby.py in __getattr__(self, attr)
    979             return self[attr]
    980 
--> 981         raise AttributeError(
    982             f"'{type(self).__name__}' object has no attribute '{attr}'"
    983         )

AttributeError: 'DataFrameGroupBy' object has no attribute 'shape'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions