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

  • Home
  • SEARCH
  • 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 8896219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:59:01+00:00 2026-06-14T23:59:01+00:00

I have a problem using the function numpy.append. I wrote the following function as

  • 0

I have a problem using the function numpy.append.
I wrote the following function as part of a larger piece of code,
however, my error is reproduced in the folowing:

data = [
         [
          '3.5', '3', '0', '0', '15', '6', 
          '441', 'some text', 'some more complicated data'
         ], 
         [
          '4.5', '5', '1', '10', '165', '0', 
          '1', 'some other text', 'some even more complicated data'
         ]
       ]

def GetNumpyArrey(self, index):
    r = np.array([])
    for line in data:
        np.append(r, float(line[index]))

    print r

index < 6.
the result is:

>> []

what am I doing wrong?

Thanks a lot !

  • 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-14T23:59:02+00:00Added an answer on June 14, 2026 at 11:59 pm

    Unlike the list append method, numpy’s append does not append in-place. It returns a new array with the extra elements appended. So you’d need to do r = np.append(r, float(line[index])).

    Building up numpy arrays in this way is inefficient, though. It’s better to just build your list as a Python list and then make a numpy array at the end.

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

Sidebar

Related Questions

I have a problem using php rename function. If I use the following syntax
I have problem when using modalPresentationStyle. I call the following function in my tabbarcontroller's
I have a problem using the string function erase with iterators. The function below
I have a problem with using a pointer to function in C++. Here is
I have an odd problem when using the return result of a function and
I am using MFC CFile Seek function. I have a problem about Seek out
I'm new in using boost and have a problem. I need shared_mutex function in
I'm having a problem with using this in js. I have a function that
i'm currently have a problem by using the SetTimeOut function. The thing is that
I have problem running and debugging this piece of code: bool readSectionHeaders(char* path, int

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.