Home > Software engineering >  Extracting elements from a list of size 1
Extracting elements from a list of size 1

Time:02-09

I have a np array of this type. It is of size 1 but there are 90 numbers in it. Is there any way I can extract all those numbers and save them as a new 1D numpy array?

    Array of int64    list    (90,)  A = [7.065590000000000000e 05   7.221840000000000000e 05 
    7.378090000000000000e 05
    1.503434000000000000e 06
    ...
    2.381593400000000000e 07
    2.383155900000000000e 07
    2.384718400000000000e 07]

CodePudding user response:

Try this to get, e.g., the 49th element:

A[0][49]

To save the numbers in a 1D array, use this:

A = A[0]

CodePudding user response:

As per my understanding of your question, if all the numbers are separated with spaces, you can use split() method in python and and store them individually.

s=str(a[0])
x=s.split()
result=map(float, x)

you can convert this map object result to your required 1D array type.

  •  Tags:  
  • Related