In this short NumPy tutorial, we are going to learn how to convert a float array to an integer array in Python. Specifically, here we are going to learn by example how to carry out this rather simple conversion task. First, we will change the data type from float to integer in a 1-dimensional array. Second, we will convert float to integer in a 2-dimensional array.
Now, sometimes we may want to round the numbers before we change the data type. Thus, we are going through a couple of examples, in which we 1) round the numbers with the round() method, 2) round the numbers to the nearest largest with the ceil() method, 3) round the float numbers to the nearest smallest numbers with floor() method. Note all code can be found in a Jupyter Notebook.