Created
April 28, 2018 12:47
-
-
Save kocur4d/8fdbda894a9e71d0757f4d4714794c9c to your computer and use it in GitHub Desktop.
Padding np.array with constant data
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
data = np.array([1,2,3,4,5]) | |
np.pad(data, (2, 3), 'constant', constant_values=9) | |
# [9,9,1,2,3,4,5,9,9,9] | |
np.pad(data, (0, 3), 'constant', constant_values=9) | |
# [1,2,3,4,5,9,9,9] | |
np.pad(data, (2, 0), 'constant', constant_values=9) | |
# [9,9,1,2,3,4,5] | |
np.pad(data, (2, 3), 'constant', constant_values=(8,9)) | |
# [8,8,1,2,3,4,5,9,9,9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment