Skip to content Skip to sidebar Skip to footer

Python: Split Numpy Array

I have an array produced by numpy which looks as follows: [ 54.51399994 -12.10200024 -11.88099957] [ 56.23899841 -8.30799961 -2.03500009] How do i convert this to a list? So

Solution 1:

You could use astype() to create a new array of string dtype:

import numpy as np
arr=np.array([
    ( 54.51399994, -12.10200024, -11.88099957),
    ( 56.23899841, -8.30799961, -2.03500009)])
print(arr.astype('|S10'))

yields

[['54.51399994', '-12.10200024', '-11.88099957'], ['56.23899841', '-8.30799961', '-2.03500009']]

Post a Comment for "Python: Split Numpy Array"