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

Expanding arrays

The concatenate function allows binding arrays together along a common axis, using the syntax seen on the screen. This approach requires that the arrays have similar shapes along the axes not used for binding. The result is a brand new ndarray that is the product of this gluing of arrays together. Other similar functions exist for this purpose, such as stack. We will not cover all of them.

Let's suppose that we want to add more rows to arr2. Use the following code to do this:

We create a brand new array. We don't need to use the copy method in this situation. This is the result:

We have added a fourth row to this array, binding ...

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