You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
value_counts to support multidimensional pdarrays #4962
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).
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.
Activity
ajpotts commentedon Oct 1, 2025
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).
drculhane commentedon Oct 7, 2025
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.
Closes #4962, adds multi-dim to value_counts (#4988)