[Python] How to process Python Pandas data frames in batches?

Discussão em 'Python' iniciado por Stack, Abril 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have three very long lists of Pandas data frames. For example:

    list_a = [tablea1, tablea2, tablea3, tablea4]

    list_b = [tableb1, tableb2, tableb3, tableb4]

    list_c = [tablec1, tablec2, tablec3, tablec4]


    I want to do something like this:

    tablea1 = pd.concat([tablea1, tableb1, tablec1], axis=1)


    So naively, I wrote such codes:

    for i in range(len(list_a)):

    list_a = pd.concat([list_a, list_b, list_c], axis=1)


    This code failed to work, b/c list_a[0] is a reference to tablea1 initially, then inside the loop, list_a[0] will be re-assigned to point to

    pd.concat([tablea1, tableb1, tablec1], axis=1),


    which is a new object. In the end, tablea1 is not modified. (list_a does contain the desired result. But I do want to modify tablea1.) I have spent hours on this and cannot find out a solution. Any help?

    Continue reading...

Compartilhe esta Página