- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy Compiler
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.concatenate
Concatenation refers to joining. This function is used to join two or more arrays of the same shape along a specified axis. The function takes the following parameters.
numpy.concatenate((a1, a2, ...), axis)
Where,
Sr.No. | Parameter & Description |
---|---|
1 | a1,a2.. Sequence of arrays of the same type |
2 | axis Axis along which arrays have to be joined. Default is 0 |
Example
import numpy as np a = np.array([[1,2],[3,4]]) print 'First array:' print a print '\n' b = np.array([[5,6],[7,8]]) print 'Second array:' print b print '\n' # both the arrays are of same dimensions print 'Joining the two arrays along axis 0:' print np.concatenate((a,b)) print '\n' print 'Joining the two arrays along axis 1:' print np.concatenate((a,b),axis = 1)
Its output is as follows −
First array: [[1 2] [3 4]] Second array: [[5 6] [7 8]] Joining the two arrays along axis 0: [[1 2] [3 4] [5 6] [7 8]] Joining the two arrays along axis 1: [[1 2 5 6] [3 4 7 8]]
numpy_array_manipulation.htm
Advertisements
To Continue Learning Please Login
Login with Google