Skip to content

Commit 6415812

Browse files
authored
Allow numpy.random.Generator as random_state input
Workaround for pandas-dev#38100
1 parent 6c15d95 commit 6415812

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/common.py

+2
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ def random_state(state=None):
425425
or (not np_version_under1p18 and isinstance(state, np.random.BitGenerator))
426426
):
427427
return np.random.RandomState(state)
428+
elif not np_version_under1p18 and isinstance(state, np.random.Generator):
429+
return np.random.RandomState(state.bit_generator)
428430
elif isinstance(state, np.random.RandomState):
429431
return state
430432
elif state is None:

0 commit comments

Comments
 (0)