转化数组x中的数据类型,使用 .astype()方法:


>>> x = np.array([1, 2, 2.5]) >>> x array([ 1. , 2. , 2.5]) >>> x.astype(int)
array([1, 2, 2])