[Python] Python pandas : Merge two tables without keys (Multiply 2 dataframes with...

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    I want to merge 2 dataframes with broadcast relationship: No common index, just want to find all pairs of the rows in the 2 dataframes. So want to make N row dataframe x M row dataframe = N*M row dataframe. Is there any rule to make this happen without using itertool?

    DF1=
    id quantity
    0 1 20
    1 2 23

    DF2=
    name part
    0 'A' 3
    1 'B' 4
    2 'C' 5

    DF_merged=
    id quantity name part
    0 1 20 'A' 3
    1 1 20 'B' 4
    2 1 20 'C' 5
    3 2 23 'A' 3
    4 2 23 'B' 4
    5 2 23 'C' 5

    Continue reading...

Compartilhe esta Página