How to concatenate multiple dataframes having different column names and length

I am having multiple dataframes. All are having different column names and lengths. For example df1 has columns like ['c1', 'c2', 'c3'], df2 has columns like ['d1', 'd2', 'd3', 'd4'] and so on.

I want to concatenate all the dfs one under another. I don’t care about the column name preservation. Resultant df will have all the values of df1 and df2 and so on.

Right now I’m doing pd.concat([df1, df2], axis=0) which is making the resultant df both df1 and df2 columns side by side. I want them one under another.


If column names isn’t important, we can also consider taking the numpy values of the dataframes by DataFrame.values and concat together using pd.concat(), like below:

pd.concat([pd.DataFrame(dfi.values) for dfi in [df1, df2]], ignore_index=True)