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 7672987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:24:35+00:00 2026-05-31T16:24:35+00:00

I have a numpy array like this a = np.array(1) Now if I want

  • 0

I have a numpy array like this

a = np.array(1)

Now if I want to get 1 back from this array, how do I retrieve this?

I have tried

a[0], a(0)

but they give error:

IndexError: 0-d arrays can't be indexed

or

TypeError: 'numpy.ndarray' object is not callable

I even tried to do some weird flattening but I am pretty sure that it shouldn’t be that complicated. I am getting errors in both. All I want is that 1 as an int?

  • 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-05-31T16:24:36+00:00Added an answer on May 31, 2026 at 4:24 pm

    What you create with

    a = np.array(1)
    

    is a zero-dimensional array, and these cannot be indexed. You also don’t need to index it — you can use a directly as if it were a scalar value. If you really need the value in a different type, say float, you can explicitly convert it with float(a). If you need it in the base type of the array, you can use a.item() or a[()].

    Note that the zero-dimensional array is mutable. If you change the value of the single entry in the array, this will be visible via all references to the array you stored. Use a.item() if you want to store an immutable value.

    If you want a one-dimensional array with a single element instead, use

    a = np.array([1])
    

    You can access the single element with a[0] now.

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

Sidebar

Related Questions

I have a NumPy array [1,2,3,4,5,6,7,8,9,10,11,12,13,14] and want to have an array structured like
I have a 2d numpy array Something like this: [[ 1 2 3 4],
Assuming I have a numpy array like: [1,2,3,4,5,6] and another array: [0,0,1,2,2,1] I want
I have an array like this numpy array dd= [[foo 0.567 0.611] [bar 0.469
I have an array like this numpy array dd =[[0.567 2 0.611] [0.469 1
I have a Numpy rec array from which I would like to do some
I have a 2-dimensional numpy array that looks like this: [[a b c] [d
I have a numpy.ndarray like this: array([[ 11.18033989, 0. ], [ 8.24621125, 3. ],
I have a Numpy array that looks like >>> a array([[ 3. , 2.
My vertices are interleaved in a numpy array (dtype = float32) like this: ...

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.