About 51 results
Open links in new tab
  1. Sum a list of numbers in Python - Stack Overflow

    464 This question already has answers here: How do I add together integers in a list (sum a list of numbers) in python? (5 answers) How can I iterate over overlapping (current, next) pairs of values …

  2. How the sum() function works in python? - Stack Overflow

    Nov 17, 2018 · As explained on Python's documentation, the sum function will sum the start value (2nd argument) with the items from an iterable data structure (1st argument). And, as mentioned on the …

  3. python - What does the built-in function sum do with sum (list ...

    Nov 5, 2015 · What does the built-in function sum do with sum (list, [])? Asked 10 years, 3 months ago Modified 6 years, 8 months ago Viewed 15k times

  4. python - How do I sum values in a column that match a given …

    Jan 30, 2015 · Suppose I have a dataframe like so: a b 1 5 1 7 2 3 1 3 2 5 I want to sum up the values for b where a = 1, for example. This would give me 5 + 7 + 3 = 15. How do I do this in pandas?

  5. python - Sum the digits of a number - Stack Overflow

    If I want to find the sum of the digits of a number, i.e.: Input: 932 Output: 14, which is (9 + 3 + 2) What is the fastest way of doing this? I instinctively did: sum (int (digit) for digit in str (...

  6. python - Pandas: sum DataFrame rows for given columns - Stack …

    You can just sum and set axis=1 to sum the rows, which will ignore non-numeric columns; from pandas 2.0+ you also need to specify numeric_only=True.

  7. How to sum a 2d array in Python? - Stack Overflow

    May 23, 2012 · One of the nice (and idiomatic) features of Python is letting it do the counting for you. sum() is a built-in and you should not use names of built-ins for your own identifiers.

  8. python - How to find the cumulative sum of numbers in a list? - Stack ...

    1 In Python3, To find the cumulative sum of a list where the i th element is the sum of the first i+1 elements from the original list, you may do:

  9. How do I add together integers in a list (sum a list of numbers) in …

    Dec 17, 2012 · Suppose I have a list of integers like [2, 4, 7, 12, 3]. How can I add all of the numbers together, to get 28?

  10. How do I use Pandas group-by to get the sum? - Stack Overflow

    12 You could also use transform() on column Number after group by. This operation will calculate the total number in one group with function sum, the result is a series with the same index as original …