1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to get rows with unique value in a specific column in pandas

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

  1. Stack

    Stack Membro Participativo

    Following is my data frame.

    id name class
    --------------------------
    0 Nick a
    1 Jane b
    2 Jacon a
    3 Jack b
    4 Cooze a
    --------------------------
    5 Nick b
    6 Jane b
    7 Jacon c
    8 Jack a
    9 Cooze a


    I need to get all names that have unique value in class column, i.e.:

    id name class count
    -----------------------------------
    0 Jane b 2
    1 Cooze a 2



    How can I do this in pandas? Thanks in advance.

    Continue reading...

Compartilhe esta Página