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

rand(::GroupedDataFrame) sampler? #2097

Closed
anandijain opened this issue Feb 2, 2020 · 4 comments
Closed

rand(::GroupedDataFrame) sampler? #2097

anandijain opened this issue Feb 2, 2020 · 4 comments
Labels
grouping non-breaking The proposed change is not breaking

Comments

@anandijain
Copy link
Contributor

Hello,
I was wondering if there is a reason that a Sampler for the rand function is not practical for the GroupedDataFrame type.
It seems like a relatively easy and useful feature.
Thanks

@bkamins
Copy link
Member

bkamins commented Feb 2, 2020

GroupedDataFrame does not allow duplicates and rand does return them in general if passed a dimension. Also it is easy enough to write gdf[rand(1:lengh(gdf))] if you want to pick a single group at random or [gdf[rand(1:lengh(gdf))] for _ in 1:how_many] if you want many of them.

@anandijain
Copy link
Contributor Author

definitely, hear you on gdf[rand(1:lengh(gdf))]
I still don't fully understand why rand(gdf) shouldn't work though.

@bkamins
Copy link
Member

bkamins commented Feb 3, 2020

rand(gdf) could work, but then we would not be able to support the whole rand API, which is defined as:

Pick a random element or array of random elements from the set of values specified by S

However it would be possible to support rand(gdf) and that is why I have not closed this issue to let people comment (this is a similar decision to: #2048, it is easy to add it, but it is also easy to have the functionality without adding it).

@bkamins
Copy link
Member

bkamins commented Apr 18, 2024

After the discussion in #3437 I am closing this issue.

@bkamins bkamins closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grouping non-breaking The proposed change is not breaking
Projects
None yet
Development

No branches or pull requests

2 participants