[Python] Pandas head with offset

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

  1. Stack

    Stack Membro Participativo

    What is the suggested way to get, for example, the first X rows after an offset of Y? What I'm currently doing is:

    offset, limit = 2, 2
    df=pd.DataFrame([{'a':1}, {'a': 2}, {'a':3}, {'a': 4}, {'a':5}])
    df.head(offset+limit)[offset:]
    # a
    # 2 3
    # 3 4


    Is there a better way to do this?

    Continue reading...

Compartilhe esta Página