O'Reilly logo

Hands-On Data Analysis with NumPy and pandas by Curtis Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required