Skip to content

Support axis=None in all reductions #21597

Closed
@TomAugspurger

Description

@TomAugspurger

#21486 is implementing support for axis=None for compatibility with NumPy 1.15's all / any.

The basic idea is to have df.op(axis=None) be the same as np.op(df, axis=None) for reductions like sum, mean, etc.

Getting there poses a backwards-compatibility challenge. Currently for some reduction functions like np.sum we interpret axis=None as

In [11]: df = pd.DataFrame({"A": [1, 2]})

In [12]: np.sum(df)
Out[12]:
A    3
dtype: int64

The best I option I see is to just warn that the behavior will change in the future, without providing a way to achieve the behavior today. Then users can update things like np.sum(df) to np.sum(df, axis=0). In a later version we'll make the actual change to interpret axis=None like NumPy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions