sum

Calculate the sum of column values per row but not include every value

Calculate the sum of column values per row but not include every value Question: So I have this dataset which looks like this. id something number1 number2 number3 number4 number5 number6 sum_columns 1 105 1 NaN NaN 2 3 4 4 2 300 2 1 1 33 6 2 6 3 20 1 NaN NaN …

Total answers: 1

Sums generated with given integers

Sums generated with given integers Question: I’m trying to make a program that calculates the different sums that can be generated with the given integers. I’m not quite getting the hang of things, and I don’t really understand where and what to edit in the code. I’m trying to follow the following rule (examples) list …

Total answers: 2

Python: sum column for every dataframe in a list

Python: sum column for every dataframe in a list Question: I have a list of identical dataframes and I am trying to sum one column in each dataframe in the list. My thought is something like total = [df[‘A’].sum for df in dfs] but this returns a list of length dfs containing only the value …

Total answers: 1

sum up a numeric string (1111 = 1+1+1+1=4)

sum up a numeric string (1111 = 1+1+1+1=4) Question: #Develop a program that reads a four-digit integer from the user and displays the sum of the digits in the number. For example, if the user enters 3141 then your program should display 3+1+4+1=9. ri = input("please enter four digits") if len(ri) == 4 and ri.isnumeric() …

Total answers: 5

Convert negative results from the list into 0 in Python

Convert negative results from the list into 0 in Python Question: I’ve done a program which counts income per family member and gives a result of funding. There is a problem when one of the family member’s "earns negative value" (has a loss), I want it to count negative values as 0. Example of right …

Total answers: 3

How do I save incremented Numbers and calculate them?

How do I save incremented Numbers and calculate them? Question: I want to write myself a program where a variable is going to increment everytime in the while-loop and want at the end, that all values will be stored in a list. At the end the values of the list should be summed with sum(). …

Total answers: 1

instead of summing the two values, it just repeats it

instead of summing the two values, it just repeats it Question: my code in python is supposed to sum the two variables and return a value, but it keeps returning the two numbers together: A = input("insert a value: ") B = input("insert another value: ") if A >= B: R == A + B …

Total answers: 2