Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Copying Arrays | Important Functions
NumPy in a Nutshell

Copying ArraysCopying Arrays

It's worth noting that NumPy offers various methods for duplicating arrays. In this section, we'll explore one of these methods, namely: .copy().

Note

The .copy() method creates a new array with the data from the original one.

Using the .copy() method:

Task

You have the following array: [12, 56, 78, 65, 1, 5].

You have to obtain the following arrays using the correct method: arr_1 = [11, 56, 78, 0, 1, 5] arr_2 = [12, 56, 78, 65, 1, 5]

Replace element 12 with 11, and element 65 with 0.

Everything was clear?

Section 4. Chapter 5
toggle bottom row
course content

Course Content

NumPy in a Nutshell

Copying ArraysCopying Arrays

It's worth noting that NumPy offers various methods for duplicating arrays. In this section, we'll explore one of these methods, namely: .copy().

Note

The .copy() method creates a new array with the data from the original one.

Using the .copy() method:

Task

You have the following array: [12, 56, 78, 65, 1, 5].

You have to obtain the following arrays using the correct method: arr_1 = [11, 56, 78, 0, 1, 5] arr_2 = [12, 56, 78, 65, 1, 5]

Replace element 12 with 11, and element 65 with 0.

Everything was clear?

Section 4. Chapter 5
toggle bottom row
some-alt