[Python] How to get slice of list which is in a pandas series [duplicate]

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    numbers = df_data['prize_share'].str.split('/')


    Here is numbers:

    [​IMG]

    (Without using .split, it would be a fraction like 1/1 or 1/4)

    I want to now create a new column which gives us the percentage of the fraction (100% for 1/1, 50% for 1/2, 25% for 1/4, e.t.c)

    For that, I did this:

    df_data['share_pct'] = float(int(numbers[0]) / int(numbers[1]))


    But then I realized that numbers[0] was [1,1] instead of a series, so I am confused how to go forward with this.

    Continue reading...

Compartilhe esta Página