Skip to content

Instantly share code, notes, and snippets.

@mohanadkaleia
Created August 15, 2017 15:20
Show Gist options
  • Save mohanadkaleia/3efcdb97cfeaa681c19fa379794be2d3 to your computer and use it in GitHub Desktop.
Save mohanadkaleia/3efcdb97cfeaa681c19fa379794be2d3 to your computer and use it in GitHub Desktop.
When you have 2D array, shuffle functionality in python numpy does the trick only for rows, the following gist is how to randomly shuffle rows and columns
import numpy as np
# Lets suppose you have a 2D array
c = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Suffle it for rows and columns
np.random.permutation(np.random.permutation(c.transpose()).transpose())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment