import numpy as np raw = np.array(["1.25", "2.50", "3.75"]) floats = raw.astype(np.float64) truncated = floats.astype(np.int64) whole = np.array([10.0, 20.0, 30.0]) exact_int = whole.astype(np.int64, casting="same_value") print("raw dtype:", raw.dtype, raw) print("float dtype:", floats.dtype, floats) print("truncated int dtype:", truncated.dtype, truncated) print("exact int dtype:", exact_int.dtype, exact_int) try: floats.astype(np.int64, casting="same_value") except ValueError as error: print("strict cast error:", error)