About 220,000 results
Open links in new tab
  1. How to sum a 2d array in Python? - Stack Overflow

    May 23, 2012 · I want to sum a 2 dimensional array in python: Here is what I have: def sum1(input): sum = 0 for row in range (len(input)-1): for col in range(len(input[0])-1): sum = …

  2. How would I sum a multi-dimensional array in the most succinct python

    Feb 29, 2012 · sum(map(sum, my_list)) or alternatively. sum(sum(x) for x in my_list)) and call it a day, if you don't expect more than 2 dimensions. Note that the first solution is most likely not …

  3. numpy.sumNumPy v2.2 Manual

    Sum of array elements over a given axis. Elements to sum. Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is …

  4. Sum 2D array in Python using map() function - GeeksforGeeks

    Jul 21, 2022 · Given a 2-D matrix, we need to find sum of all elements present in matrix ? Examples: Input : arr = [[1, 2, 3], [4, 5, 6], [2, 1, 2]] Output : Sum = 26. This problem can be …

  5. python - How do I sum the columns in 2D list? - Stack Overflow

    import numpy as np my_list = np.array([[1,2,3,4],[2,4,5,6]]) [ sum(x) for x in my_list.transpose() ] Out[*]: [3, 6, 8, 10] Or, simpler: my_list.sum(axis = 0)

  6. Sum 2D Array in Python Using Map Function - Online Tutorials …

    Feb 12, 2020 · Learn how to sum a 2D array in Python using the map function. This guide provides step-by-step instructions and examples.

  7. Python Numpy sum () - Calculate Array Sum | Vultr Docs

    Jan 1, 2025 · The numpy.sum() function in Python provides a robust platform for conducting summative analyses on arrays. From handling simple one-dimensional arrays to more …

  8. Python 2D Arrays: Two-Dimensional List Examples

    Jan 24, 2024 · In Python, we can create 2D arrays using lists, providing a versatile tool for various applications. This blog post will delve into the world of Python 2D arrays, exploring their …

  9. Program to find sum of elements in a given 2D array

    Mar 29, 2023 · Define a function named sum that takes a 2D array of integers as input and returns an integer value. In the sum function, declare a pointer ptr of type integer and assign it the …

  10. numpy.sum() in Python - GeeksforGeeks

    Aug 28, 2024 · This Python program uses numpy.sum() to compute the sum of elements in a 2D array. It calculates the total sum, sums along rows (axis=0), sums along columns (axis=1), and …

  11. Some results have been removed
Refresh