[Python] TypeError: 'Series' objects are mutable, thus they cannot be hashed

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

  1. Stack

    Stack Membro Participativo

    I know this error is common, I tried some solutions I looked up and still can't understand what is wrong. I guess it is due to the mutable form of row and row1, but i can't figure it out

    What am I trying to do ? I have 2 dataframes. I need to iterate over the rows of the first 1, and for each line of the first one iterate through the second and check the value of the cell for some columns. My code and different attempts :

    a=0
    b=0
    for row in Correction.iterrows():
    b+=1
    for row1 in dataframe.iterrows():
    c+=1
    a=0
    print('Handling correction '+str(b)+' and deal '+str(c))
    if (Correction.loc[row,['BO Branch Code']]==dataframe.loc[row1,['wings Branch']] and Correction.loc[row,['Profit Center']]==dataframe.loc[row1,['Profit Center']] and Correction.loc[row,['Back Office']]==dataframe.loc[row1,['Back Office']]
    and Correction.loc[row,['BO System Code']]==dataframe.loc[row1,['BO System Code']]):


    I also tried

    a=0
    b=0
    for row in Correction.iterrows():
    b+=1
    for row1 in dataframe.iterrows():
    c+=1
    a=0
    print('Handling correction '+str(b)+' and deal '+str(c))
    if (Correction[row]['BO Branch Code']==dataframe[row1]['wings Branch'] and Correction[row]['Profit Center']==dataframe[row1]['Profit Center'] and Correction[row]['Back Office']==dataframe[row1]['Back Office']
    and Correction[row]['BO System Code']==dataframe[row1]['BO System Code']):


    And

    a=0
    b=0
    for row in Correction.iterrows():
    b+=1
    for row1 in dataframe.iterrows():
    c+=1
    a=0
    print('Handling correction '+str(b)+' and deal '+str(c))
    if (Correction.loc[row,['BO Branch Code']]==dataframe[row1,['wings Branch']] and Correction[row,['Profit Center']]==dataframe[row1,['Profit Center']] and Correction[row,['Back Office']]==dataframe[row1,['Back Office']]
    and Correction[row,['BO System Code']]==dataframe[row1,['BO System Code']]):

    Continue reading...

Compartilhe esta Página