python numpy change dtype code example Example 1: change type of array python arr=arr.astype('uint8') Example 2: np as type >>> x.astype(int) array([1, 2, 2])