감동, 마음이 움직이는 것

[python] array with the initial value np.full() 본문

Tips (Utility, Computer Language, and etc.)

[python] array with the initial value np.full()

Struggler J. 2017. 8. 16. 03:31

[Ref] https://stackoverflow.com/questions/5891410/numpy-array-initialization-fill-with-identical-values

>>> np.full((3, 5), 7)
array([[ 7.,  7.,  7.,  7.,  7.],
       [ 7.,  7.,  7.,  7.,  7.],
       [ 7.,  7.,  7.,  7.,  7.]])

>>> np.full((3, 5), 7, dtype=int)
array([[7, 7, 7, 7, 7],
       [7, 7, 7, 7, 7],
       [7, 7, 7, 7, 7]])