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

DOC: document default behaviour of sample methods when random_state = None #59073

Merged

Conversation

alexmalins
Copy link
Contributor

Docs improvement to make it clear what the DataFrame/Series/GroupBy sample methods do when no argument is supplied for random_state. TLDR it just defers to np.random to draw random samples, so the state is whatever the current random state of np.random is.

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Previously the default random state of the Series/DataFrame/GroupBy
`sample` methods was unclear as the documentation for the behaviour
when `random_state=None` was hidden in the
`pandas.core.common.random_state` helper function.

This commit documents how `sample` will just defer to the random state
of `numpy.random` when no `random_state` parameter is passed.
pandas/core/generic.py Outdated Show resolved Hide resolved
@mroeschke mroeschke added the Docs label Jun 24, 2024
@mroeschke mroeschke added this to the 3.0 milestone Jun 25, 2024
@mroeschke mroeschke merged commit 46916db into pandas-dev:main Jun 25, 2024
44 checks passed
@mroeschke
Copy link
Member

Thanks @alexmalins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants