We make use of the concat()
function to concatenate, join or link pandas objects (DataFrame or series) along a specified axis.
The concat()
function takes the syntax given below:
pandas.concat(objs, axis=0, join='outer', ignore_index=False, levels=None, names=None, verify_integrity=False, copy=True)
The concat()
function takes the following parameter values:
obj
(required): This represents a sequence or mapping of Dataframe or series objects.axis
(optional): This represents the axis along which the concatenation is done.join
(optional): This is used in handling the indexes on other axis.ignore_index
(optional): This takes a Boolean value indicating if the index values along the concatenation axis is used (if False
) or not be used (if True
).levels
(optional): This represents the specific levels which are used for constructing a multiple index.names
(optional): This represents the names for the levels.verify_integrity
(optional): This is used to test if the new linked axis contains duplicate or not.copy
(optional): This takes a Boolean value indicating if the data is copied or not.import pandas as pd# creating a dataframea = pd.Series(['A', 'B', 'C', 'D', 'E'])b = pd.Series(['F', 'G', 'H', 'I', 'J'])# concatenating the seriesd = pd.concat([a,b], ignore_index="True")# printing the concatenated seriesprint(d)
Here's an explanation of the above code:
a
and b
using the series()
function.a
and b
using the concat()
function. The result is assigned to a variable, d
.d
.