pandas.concat()
function does all the heavy lifting of performing
concatenation operations along with an axis od Pandas objects while performing optional set logic (union or intersection) of the indexes (if any) on the other axes.
Syntax : concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
Parameters :
objs : Series or DataFrame objects
axis : axis to concatenate along; default = 0
join : way to handle indexes on other axis; default = ‘outer’
ignore_index : if True, do not use the index values along the concatenation axis; default = False
keys : sequence to add an identifier to the result indexes; default = None
levels : specific levels (unique values) to use for constructing a MultiIndex; default = None
names : names for the levels in the resulting hierarchical index; default = None
verify_integrity : check whether the new concatenated axis contains duplicates; default = False
sort : sort non-concatenation axis if it is not already aligned when join is ‘outer’; default = False
copy : if False, do not copy data unnecessarily; default = True
Returns : type of objs (Series of DataFrame)
Example : Concatenating 2 Series with default parameters.
import numpy as np
import pandas as pd
s1 = pd.Series(['a', 'b'])
s2 = pd.Series(['c', 'd'])
print(pd.concat([s1, s2]))
Output :
0 a
1 b
0 c
1 d
dtype: object