[Python] How to sum up a particular row of number inputs in a DataFrame

Discussão em 'Python' iniciado por Stack, Agosto 31, 2025.

  1. Stack

    Stack Membro Participativo

    I want to add the inputs in a particular row of data frame as total. But the output is

    XYZ: OBJECT1 Object2
    NUMBERS: 1 2


    Where the inputted XYZ are Object2 and OBJECT1 and the inputted Numbers are 1 and 2 I want the output to be only the data frame and total of 1 and 2 Numbers (i.e. 1+2=3) so far I have tried

    dd=pd.DataFrame([list , list2], index=["xyz", "numbers"], columns=[str(i+1) for i in range (do)])
    print (dd)
    total= dd.sum(axis=1)
    print(total)


    I want the output to be only the dataframe and total of 1 and 2 Numbers (i.e. 1+2=3)

    Continue reading...

Compartilhe esta Página