Search this site
Embedded Files
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
  • More
    • Home
    • Courses
    • Contact

日本語  ❯

Lesson 5    ❮    Lesson List    ❮    Top Page

5.1 NumPy Arrays      

5.2 Index and Reshape

5.3 Universal Functions   

❯  5.4  Join, Split, and Transpose

5.5 Search and Filter      

⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
EXPECTED COMPLETION TIME
❲▹❳  Video   5m 34s
☷  Interactive readings   5m
✑  Practice 5.4 (G Colab)   20m

Joining NumPy Arrays

Joining means putting contents of two or more arrays in a single array.

np.concatenate((arr1, arr2, ...))
joins arr1, arr2, ..., along with the axis. If axis is not explicitly passed, it is taken as 0.

Splitting NumPy Arrays

Splitting is the reverse operation of Joining. It breaks one array into multiple.

np.array_split(arr, num)
split arr into num sub-arrays. It will return a list object (not ndarray).

Joining Arrays using Stack Functions

Stacking is the same as concatenation, the only difference is that stacking is done along a new axis.

We can concatenate two 1-D arrays along the second axis which would result in putting them one over the other, ie. stacking.

np.vstack([arr1, arr2, ...])
stack arr1, arr2, ..., in sequence vertically (row wise).

np.hstack([arr1, arr2, ...])
stack arr1, arr2, ..., in sequence horizontally (column wise).

Transposing Arrays

Swapping axes can be necessary to form the data into a better format. This can be done by transposing the array.

np.transpose(arr)
reverse the axes of arr and returns the modified array.

©2023. All rights reserved.  Samy Baladram,
Graduate Program in Data Science - GSIS - Tohoku University
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse