numpy.random.shuffle(x)

Modify a sequence in-place by shuffling its contents.

Parameters:

x : array_like

The array or list to be shuffled.

Returns:

None

Examples

>>>
>>> arr = np.arange(10)
>>> np.random.shuffle(arr)
>>> arr
[1 7 5 2 9 4 3 6 0 8]

This function only shuffles the array along the first index of a multi-dimensional array:

>>>
>>> arr = np.arange(9).reshape((3, 3))
>>> np.random.shuffle(arr)
>>> arr
array([[3, 4, 5],
       [6, 7, 8],
       [0, 1, 2]])

相关文章:

  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
猜你喜欢
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
相关资源
相似解决方案