ENH: DataFrame.sample should accept numpy.random.Generator #44486
Labels
Algos
Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff
Compat
pandas objects compatability with Numpy or Python functions
Enhancement
Uh oh!
There was an error while loading. Please reload this page.
This seems to be related to this issue and this merge. But currently DataFrame.sample does not allow Generator objects for random_state.
Rationale
As far as I can tell, the convention for numpy 1.21 random sampling, in their documentation is to create Generators using numpy.random.default_rng, so creating BitGenerators directly seems a little awkward.
Fix
This is a quick fix though because the generator has field to access the bit generator
from numpy.random import default_rng
rng = default_rng()
bit_generator = rng.bit_generator
The text was updated successfully, but these errors were encountered: