I have a list with different dataframes.I need to merge the dataframes with the same column names into one and write it to a CSV output or single dataframe.
I have managed to get the column names,but not able to think of good logic to perform the above operation.
My case:
There is MERGED_LIST with 9 dataframe elements.The column names are as below
array(['A','B','C']) - 10 rows
array(['A','B','C']) - 15 rows
array(['W','X','Y','Z']) - 10 rows
array(['W','X','Y','Z']) - 20 rows
array(['W','X','Y','Z']) - 45 rows
array(['W','X','Y','Z']) - 30 rows
array(['W','X','Y','Z']) - 5 rows
array(['H']) - 50 rows
Final outpout needed:
CSV1 or DF1:
A B C
with 25 rows
CSV2 or DF2:
W X Y Z
with 110 rows
CSV3 or DF3:
H
with 50 rows
,axis=0). It will do its job. Now, the varying number of columns presents a challenge, but it shouldn't matter if you find a good algorithm. I would start by exploring this direction: select a column, run method notnull(), then check result against the same for the other columns -- this will give you which columns group together. then splitting is a matter technique.
– Sergey Antopolskiy Jan 19 '16 at 10:24