Python Forum
How to get the size of a numpy array?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get the size of a numpy array?
I am having some problems with this task.
I am supposed to use the command range to generate a list of 100 numbers
between 0 and 1 (both 0 and 1 should be included) and a list comprehension.

I have tried by using np.arange, but as a fairly new user, I am not sure if is the same
thing as range. I have tried to use 'range' before but it does not work with floats.
Since the numbers needed to be generated must be 100, I have tried to look for a specific
command that allows me to find out how many numbers are generated, but I haven't had any success.
Here is the code:

import numpy as np
from scipy import *
from numpy import array

for i in np.arange(0, 1.01, 0.0101):

    print(i, end=', ')
“100 numbers between 0 and 1 (both 0 and 1 should be included)”

I observe that if evenly distributed there will be 101 numbers: 0, 0.01, 0.02, .... 0.99, 1
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to fill datetime64 field in numpy structured array? AlekseyPython 0 111 Oct-20-2020, 08:17 AM
Last Post: AlekseyPython
  Adding data in 3D array from 2D numpy array asmasattar 0 420 Jul-23-2020, 10:55 AM
Last Post: asmasattar
  cannot reshape array of size 0 into shape Roro 2 1,241 Jun-14-2020, 11:28 AM
Last Post: Roro
  converting dataframe to int numpy array glennford49 1 485 Apr-04-2020, 06:15 AM
Last Post: snippsat
  Replacing sub array in Numpy array ThemePark 5 679 Apr-01-2020, 01:16 PM
Last Post: ThemePark
  How to prepare a NumPy array which include float type array elements subhash 0 405 Mar-02-2020, 06:46 AM
Last Post: subhash
  numpy.where array search for string in just one coordinate adetheheat 1 576 Jan-09-2020, 07:09 PM
Last Post: paul18fr
  memory issue loading movie to numpy array djf123 1 495 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 796 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 17,905 May-29-2019, 02:48 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020