sum axis in python

import numpy as np

array1 = np.array(
    [[1, 2],
     [3, 4],
     [5, 6]])

total_0_axis = np.sum(array1, axis=0)
print(f'Sum of elements at 0-axis is {total_0_axis}')

total_1_axis = np.sum(array1, axis=1)
print(f'Sum of elements at 1-axis is {total_1_axis}')
Output:


Sum of elements at 0-axis is [ 9 12]
Sum of elements at 1-axis is [ 3  7 11]

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
The sum along axis in python sum axis pandas sum axis python .sum(axis) python sum(axis=1) sum along axis python .sum(axis = 1) python sum axis .sum(axis=1) .sum(axis=1) python np.sum() in python sum in numpy python sum np array by axis pytorch tensor sum axis python np.su get sum of numpy array numpy .sum numpy.sum function how to find the sum of all the elements of a numpy array how to sum the matrix array in python row sum y axis array python sum all rows of a 2d array numpy python np.sum axis python np.sum np.sum() sum along an axis numpy sum numpy arrays python np.sum axis=1 sum(axis=1) Which of the following gives the sum of the elements of the array .in numpy numpy arange function for column sum numpy sum specific elements sum all elements array numpy how to use np.sum np sum of values in column np.sum array sum along row in np python sum function matrix numpy.sum sum one python create np array of sums sum array in numpy how to get sum of all row in an array in python using numpy np.sum summing rows in numpy nimpy get sum how to do row sum to array python using numpy np sum axis0 how to sum n rows in numpy how to sum n columns in numpy how to do row wise addition in numpy sum of all elements of numpy array sum(axis=1) python numpy sum array by row python array sum axis 1 np array sum axis in numpy sum np.sum in python sum upto specific index numpy.sum function how to find sum of all elements in list numpy sum of all elements in an array python using numpy sum of elements in an array python using numpy row sum in numpy sum numpy array numpy sum rows numpy sum along axis numpy sum over axis np.sum python sum of all elements in array python numpy how to get sum of numpy integer array numpy sum sum of numpy array numpy sum of all entries sum a column in python numpy calculate sum of values in numpy sum all elements in numpy array python numpy array sum column sum function in python 3 with axis sum axis in python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source