使用numpy中的astype()方法可以实现,示例如下:


x
Out[20]: 
array([[ 5.        ,  4.        ],
       [ 4.        ,  4.33333333],
       [ 3.66666667,  4.5       ]])

x.astype(int)
Out[21]: 
array([[5, 4],
       [4, 4],
       [3, 4]])



参考:http://stackoverflow.com/questions/10873824/how-to-convert-2d-float-numpy-array-to-2d-int-numpy-array