[Python] Differences between columns containing lists

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I have a data frame where the columns values are list and want to find the differences between two columns.

    data={'NAME':['JOHN','MARY','CHARLIE'],
    'A':[[1,2,3],[2,3,4],[3,4,5]],
    'B':[[2,3,4],[3,4,5],[4,5,6]]}
    df=pd.DataFrame(data)


    Why doesn't it work?

    df = df.assign(X1 = lambda x: [y for y in x['A'] if y not in x['B']])


    I get error :


    TypeError: unhashable type: 'list'
    ​

    I don't understand why?

    Continue reading...

Compartilhe esta Página