import numpy as np
arr = np.array([1, 2, 3, 4])
# print array datatype
print(arr.dtype)
# output int64
# 8 byte integer datatype
arr = np.array([1, 2, 3, 4], dtype="i8")
print(arr)
# output [1 2 3 4]
# string datatype
arr = np.array([1, 2, 3, 4], dtype="S")
print(arr)
# output [b'1' b'2' b'3' b'4']
arr = np.array([1, 0, 3])
# converting arrays
arr = arr.astype(str)
print(arr)
# output ['1' '0' '3']
arr = arr.astype(float)
print(arr)
# output [1. 0. 3.]
arr = arr.astype(bool)
print(arr)
# output [ True False True]
print(arr.dtype)
# output bool
arr = np.array(["mike", "sam"])
arr = arr.astype(int)
# output ValueError: invalid literal for int() with base 10: 'mike'
# data types
# i - integer
# b - boolean
# u - unsigned integer
# f - float
# c - complex float
# m - timedelta
# M - datetime
# O - object
# S - string
# U - unicode string
# V - fixed chunk of memory for other type ( void )
import numpy as np
>>> x = np.float32(1.0)
>>> x
1.0
>>> y = np.int_([1,2,4])
>>> y
array([1, 2, 4])
>>> z = np.arange(3, dtype=np.uint8)
>>> z
array([0, 1, 2], dtype=uint8)