You can use pandas.concat()
method to merge multiple dataframes. First, put all the required dataframes in a list and pass it as an argument in pandas.concat()
method. Use ignore_index=True
as a parameter to ignore previous dataframes indexes and reset with new index. Here's an example:
main.py643 chars21 lines
Output:
main.py180 chars11 lines
In this example, we have merged 3 dataframes df1
, df2
, and df3
. merged_df
is the final dataframe that contains all the rows of df1
, df2
, and df3
. As you can see, ignore_index=True
parameter has reset the indexes for merged_df
.
gistlibby LogSnag