Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for normalize in value_counts #7342

Merged
merged 5 commits into from Mar 19, 2021
Merged

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented Mar 9, 2021

Copy link
Member

@rjzamora rjzamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @jsignell ! My only real concern is that split_out>1 may not be supported. Related test coverage would clarify if this is an issue.

dask/dataframe/core.py Outdated Show resolved Hide resolved
dask/dataframe/core.py Outdated Show resolved Hide resolved
dask/dataframe/core.py Show resolved Hide resolved
dask/dataframe/tests/test_dataframe.py Show resolved Hide resolved

if split_out > 1 and normalize:
aggregate_kwargs["length"] = (
len(self) if dropna is False else len(self.dropna())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is acceptable. Basically I needed a way to pass the total len into the split_out combine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me - I guess an "optimal" solution for multi-partition results would be to collect/aggregate/combine the counts within the first aca pass. However, I'm not sure it is completely worth the additional code complexity to do this, because the result would need to be quite large to benefit (and split_out is often 1 anyway).


if split_out > 1 and normalize:
aggregate_kwargs["length"] = (
len(self) if dropna is False else len(self.dropna())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me - I guess an "optimal" solution for multi-partition results would be to collect/aggregate/combine the counts within the first aca pass. However, I'm not sure it is completely worth the additional code complexity to do this, because the result would need to be quite large to benefit (and split_out is often 1 anyway).

@jsignell
Copy link
Member Author

Ok I will merge this if it passes the regular tests.

@jsignell jsignell merged commit 0bc155e into dask:main Mar 19, 2021
@jsignell jsignell deleted the value_counts branch March 19, 2021 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.value_counts(normalize=True) Unsupported
2 participants