[Python] Concatenate dataframe elements with common column names of list

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    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

    Continue reading...

Compartilhe esta Página