[Python] VSCode kernel crashes when trying to append a row to a list

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    I use vscode. In my notebook, I have two .csv (csv1, csv2) I'd need to crossmatch based on the value of one of their columns, the sourceID. When a match is found, an entire row of csv2 with 282 columns is written on a list, then the code goes on by looking for the next sourceID of csv1 in csv2.

    list_with_rows = []

    for rdx, rrow in csv1.iterrows():
    for cid, crow in csv2.iterrows():
    if rrow['sourceID'] == crow['sourceID']:
    list_with_rows.append(crow)


    crow has 282 columns. The issue I can't solve is that after appending three rows of csv2 to list_with_rows, the run crashes and I get "The Kernel crashed while executing code in the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure."

    I can't provide an example because csv2 is big data and maybe that's the problem.

    EDIT 1: As suggested by @Amir Roox I dropped the for loop approach and did the pandas merge one.

    result_df = csv1[['source_ID']].merge(csv2, on='source_id', how='inner')


    but now I get a

    KeyError: 'source_id'

    Continue reading...

Compartilhe esta Página