[Python] How to GroupBy a Dataframe in Pandas and keep Columns [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 24, 2025.

  1. Stack

    Stack Membro Participativo

    Given a dataframe that logs uses of some books like this:

    Name Type ID
    Book1 ebook 1
    Book2 paper 2
    Book3 paper 3
    Book1 ebook 1
    Book2 paper 2


    I need to get the count of all the books, keeping the other columns and get this:

    Name Type ID Count
    Book1 ebook 1 2
    Book2 paper 2 2
    Book3 paper 3 1


    How can this be done?

    Continue reading...

Compartilhe esta Página