feat: Allow designation of a custom name for the value_counts
"count" column
#16434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #16425.
While we don't usually (but do sometimes #15222), I think we should allow a "name" parameter here, because otherwise we are making the caller change their column names (in the case of a clash) to account for us forcing one called "count" onto them.
It is more user-friendly to allow our "count" column to be renamed, as there is no way for the caller to do so, and working around it with pre/post aliasing to maintain their original column name is pretty ugly (and verges on painful in the DataFrame case) 🤔
Example
Series
With a "name" param:
Without a "name" param achieving the same output is... not ergonomic :)
DataFrame
And it's even worse for DataFrame...
With a "name" param:
Without a "name" param we have to tie ourselves in knots to achieve the same output, first aliasing the target column and then renaming both the resulting struct column and its component fields: