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

Conteúdo do Curso

NumPy in a Nutshell

NumPy in a Nutshell

1. Getting Started with NumPy
2. Dimensions in Arrays
3. Indexing and Slicing
4. Important Functions

bookJoining

Another equally important operation in array manipulation is joining arrays. Joining arrays involves combining multiple arrays into a single array that includes all the elements from each of the original arrays.

We perform this concatenation along the specified axes:

  • if axis = 0 (which is the default value), this implies concatenating the arrays by rows;
  • if axis = 1, this means concatenating the arrays by columns.

Join two arrays:

12345678
import numpy as np array_1 = np.array([54, 6, 23, 1, 6]) array_2 = np.array([12, 67, 94, 2, 8 ]) array = np.concatenate((array_1, array_2)) print(array)
copy

Concatenate two 2-D arrays along columns (axis=1):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2), axis=1) print(array)
copy

Concatenate two 2-D arrays along rows (default axis=0):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2)) print(array)
copy
Tarefa
test

Swipe to show code editor

You have two arrays:

  1. [[12, 56, 78], [35, 1, 5]];

  2. [[ 8, 65, 3], [ 1, 2, 3]].

You have to create the following combined array:

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 3
toggle bottom row

bookJoining

Another equally important operation in array manipulation is joining arrays. Joining arrays involves combining multiple arrays into a single array that includes all the elements from each of the original arrays.

We perform this concatenation along the specified axes:

  • if axis = 0 (which is the default value), this implies concatenating the arrays by rows;
  • if axis = 1, this means concatenating the arrays by columns.

Join two arrays:

12345678
import numpy as np array_1 = np.array([54, 6, 23, 1, 6]) array_2 = np.array([12, 67, 94, 2, 8 ]) array = np.concatenate((array_1, array_2)) print(array)
copy

Concatenate two 2-D arrays along columns (axis=1):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2), axis=1) print(array)
copy

Concatenate two 2-D arrays along rows (default axis=0):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2)) print(array)
copy
Tarefa
test

Swipe to show code editor

You have two arrays:

  1. [[12, 56, 78], [35, 1, 5]];

  2. [[ 8, 65, 3], [ 1, 2, 3]].

You have to create the following combined array:

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 3
toggle bottom row

bookJoining

Another equally important operation in array manipulation is joining arrays. Joining arrays involves combining multiple arrays into a single array that includes all the elements from each of the original arrays.

We perform this concatenation along the specified axes:

  • if axis = 0 (which is the default value), this implies concatenating the arrays by rows;
  • if axis = 1, this means concatenating the arrays by columns.

Join two arrays:

12345678
import numpy as np array_1 = np.array([54, 6, 23, 1, 6]) array_2 = np.array([12, 67, 94, 2, 8 ]) array = np.concatenate((array_1, array_2)) print(array)
copy

Concatenate two 2-D arrays along columns (axis=1):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2), axis=1) print(array)
copy

Concatenate two 2-D arrays along rows (default axis=0):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2)) print(array)
copy
Tarefa
test

Swipe to show code editor

You have two arrays:

  1. [[12, 56, 78], [35, 1, 5]];

  2. [[ 8, 65, 3], [ 1, 2, 3]].

You have to create the following combined array:

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Another equally important operation in array manipulation is joining arrays. Joining arrays involves combining multiple arrays into a single array that includes all the elements from each of the original arrays.

We perform this concatenation along the specified axes:

  • if axis = 0 (which is the default value), this implies concatenating the arrays by rows;
  • if axis = 1, this means concatenating the arrays by columns.

Join two arrays:

12345678
import numpy as np array_1 = np.array([54, 6, 23, 1, 6]) array_2 = np.array([12, 67, 94, 2, 8 ]) array = np.concatenate((array_1, array_2)) print(array)
copy

Concatenate two 2-D arrays along columns (axis=1):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2), axis=1) print(array)
copy

Concatenate two 2-D arrays along rows (default axis=0):

12345678
import numpy as np array_1 = np.array([[0, 1, 2], [3, 4, 5]]) array_2 = np.array([[6, 7, 8], [9, 10, 11]]) array = np.concatenate((array_1, array_2)) print(array)
copy
Tarefa
test

Swipe to show code editor

You have two arrays:

  1. [[12, 56, 78], [35, 1, 5]];

  2. [[ 8, 65, 3], [ 1, 2, 3]].

You have to create the following combined array:

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 4. Capítulo 3
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt