Creating ndarray

In the following notebook, we create an ndarray. The first thing we're going to do is create a vector of 1s. Notice the tuple that is being passed; it contains only one number, 5. Therefore, it will be a one-dimensional ndarray with five elements:

It was automatically assigned the dtype floating-point 64:

If we want to convert this to an integer, we can attempt to do it the following way first, but the result will be garbage:

You need to be very careful when you're converting a dtype.

The correct way to do this is to first ...

Get Hands-On Data Analysis with NumPy and pandas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.