How to Convert a Float Array to an Integer Array in Python with NumPy

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.

Read more

Pandas Convert Column to datetime – object/string, integer, CSV & Excel

pandas convert string to date

In Pandas, you can convert a column (string/object or integer type) to datetime using the to_datetime() and astype() methods. Furthermore, you can also specify the data type (e.g., datetime) when reading your data from an external source, such as CSV or Excel.  In this Pandas tutorial, we will learn how to convert a column, containing … Read more