I have problems while combining a list of DataFrames in Python. First of all I got a unknown number amount of DataFrames which are stored during a for-loop as follows:
appendDataFrames.append(df)
These DataFrames have 5 columns that are always the same: |static_1|static_2|static_3|static_4|static_5|... after those 5 columns there can be a set of columns between 5 up to 400 columns. I don't know beforehand about the column-set and their naming, but it can happen that some columns have equal names over the hole set of DataFrames.
Now I want to create a overall DataFrame which contains these 5 static columns and afterwards all other columns. If values for a column are not present in one sub-DataFrame it should contain NaN e.g.
Such as follows:
>>> import pandas as pd
>>> pd.__version__
u'0.17.1'
>>> df1 = pd.DataFrame([[1, 2, 1, 2, 1, 8.59, 7.64], [1, 2, 1, 2, 1, 10.5, 17.64]],
... columns=['static_1', 'static_2', 'static_3', 'static_4', 'static_5',
... 'c1', 'c2'])
>>> df1
static_1 static_2 static_3 static_4 static_5 c1 c2
0 1 2 1 2 1 8.59 7.64
1 1 2 1 2 1 10.50 17.64
>>> df2 = pd.DataFrame([[3, 4, 3, 4, 3, 100.56, 1.58], [3, 4, 3, 4, 3, 0.50, 1.68]],
... columns=['static_1', 'static_2', 'static_3', 'static_4', 'static_5',
... 'c1', 'c3'])
>>> df2
static_1 static_2 static_3 static_4 static_5 c1 c3
0 3 4 3 4 3 100.56 1.58
1 3 4 3 4 3 0.50 1.68
Now I want to merge, concat, append, join or whatever to get a superset of all combined DataFrame resultDf like:
>>> resultDf
static_1 static_2 static_3 static_4 static_5 c1 c2 c3
0 1 2 1 2 1 8.59 7.64 NaN
1 1 2 1 2 1 10.50 17.64 NaN
2 3 4 3 4 3 100.56 NaN 1.58
3 3 4 3 4 3 0.50 NaN 1.68
Thanks in advance!

