C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Concatenating the dataNumPy's concatenate data is used to concatenate two arrays either row-wise or column-wise. It can take two or more arrays of the same shape and it concatenates row-wise as a default type i.e. axis=0. Example1:# import numpy import numpy as np arr1 = np.arange(9) arr1 arr2d_1 = array.reshape((3,3)) arr2d_1 arr2d_1 = np.arange(10,19).reshape(3,3) arr2d_1 # concatenate 2 numpy arrays: row-wise np.concatenate((arr2d_1, arr2d_2)) Output: array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [10, 11, 12],
       [13, 14, 15],
       [16, 17, 18]])
Example2:
import pandas as pd
one = pd.DataFrame({'Name': ['Parker', 'Phill', 'Smith'],'id':[108,119,127]},index=['A','B','C'])
two = pd.DataFrame({'Name': ['Terry', 'Jones', 'John'],  
                    'id':[102,125,112]},
index=['A','B','C'])
print(pd.concat([one,two]))
Output: Name id A Parker 108 B Phill 119 C Smith 127 A Terry 102 B Jones 125 C John 112 Example3:
import pandas as pd
one = pd.DataFrame({'Name': ['Parker', 'Phill', 'Smith'],'id':[108,119,127]},index=['A','B','C'])
two = pd.DataFrame({'Name': ['Terry', 'Jones', 'John'],  
                    'id':[102,125,112]},
index=['A','B','C'])
print(pd.concat([one,two],keys=['x','y']))
Output: Name id x A Parker 108 B Phill119 C Smith 127 y A Terry 102 B Jones 125 C John 112 
Next TopicPandas vs NumPy
 
 |