Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Numpy - set type

  • dtype
  • int8
import numpy as np

a = np.array([3, 4, 7], dtype='int8')
print(a)         # [3 4 7]
print(a * 3)     # [ 9 12 21]
print(a + 4)     # [ 7  8 11]
print(a.dtype)   # int8