Explore int8 to int64, float32, float64, boolean, and type casting with astype().
NumPy supports high-precision fixed-size C data types such as int32, int64, float32, float64, and bool. Explicit dtypes optimize RAM usage and GPU throughput.
Using int64 for small numbers between 1 and 10 is like shipping a feather in a massive shipping container. Using int8 saves 8x memory bandwidth!
.astype() returns a new array cast into the requested type (e.g. float64 to int32).
ints = floats.astype(np.int32)arr = np.array([1.9, 2.8]); arr.astype(int)arr = np.array([1.9, 2.8]); arr = arr.astype(np.int32).astype() does not mutate the array in place; it returns a new array.
Solve the objective below using NumPy vectorized syntax
Create `arr = np.array([1.1, 2.9, 3.5])`, cast it to `np.int32` using `.astype()`, and print it.
[1 2 3]