Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8929857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:45:46+00:00 2026-06-15T08:45:46+00:00

I have an n-dimensional array in NumPy. I would like to calculate the sum

  • 0

I have an n-dimensional array in NumPy. I would like to calculate the sum of all the elements in a slice. For instance:

if I have the following 2x2x2 3D array having the values:

z = 1
1 2
3 4

z = 2
5 6
7 8

When I get a slice for z = 1 I would like to get 10 and for z = 2 I would like to get 26.

I can use the following for a 3D space but how can I do that for n dimensional space?

(array.sum(axis = 0)).sum(axis = 0)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:45:47+00:00Added an answer on June 15, 2026 at 8:45 am

    To sum the ith slice along the dth dimension: arr.take([i], axis=d).sum()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Numpy 3 axis array whose elements are 3 dimensional. I'd like
I have a N x 2 dimensional numpy array. I would like to make
I have a one dimensional NumPy array: a = numpy.array([2,3,3]) I would like to
I have a 2-dimensional numpy array that looks like this: [[a b c] [d
I have a 3-dimensional numpy array. I'd like to display (in matplotlib) a nice
I have following 2 dimensional array input: var arr = [ ['A', ['Sun','Moon']], ['B',
I have a two-dimensional array. When I print/dump this I get the following My
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I would like to create a function that returns a numpy array if one
I have a list of values and a 1-d numpy array, and I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.