Skip to content

value_counts to support multidimensional pdarrays #4962

Closed

Description

@ajpotts

The value_counts function should support multidimensional pdarray.

Activity

  1. ajpotts commented on Oct 1, 2025

    @ajpotts
    ContributorAuthor

    NumPy doesn’t have value_counts, but the de-facto expectation is “flatten then count” (akin to np.unique(x, return_counts=True) with axis=None).
    Fix idea: for ND input, call value_counts(pda.flatten()) (or document flattening).

  2. drculhane commented on Oct 7, 2025

    @drculhane
    Contributor

    numpy does have a unique function, which similarly to pandas value_counts, and which supports an axis parameter. I think I will grab this issue and look into it.

    Update: np.unique may not be what we want. In the multi-dimensional case, it looks for unique rows, columns, or sub-matrices, not unique values. So I'm preparing a PR with the flattening suggestion Amanda makes above.

  3. self-assigned this
    on Oct 7, 2025
  4. added a commit that references this issue on Oct 15, 2025
    917d982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions