Created
August 15, 2017 15:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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