Issue
I have an object array which looks something like this
array([array([[2.4567]],dtype=object), array([[3.4567]],dtype=object), array([[4.4567]],dtype=object), array([[5.4567]],dtype=object) ... array([[6.4567]],dtype=object))
This is just an example, actual one is much bigger.
So, how do I convert this into a normal floating value numpy array.
Solution
Use numpy.concatenate
:
>>> arr = array([array([[2.4567]],dtype=object),array([[3.4567]],dtype=object),array([[4.4567]],dtype=object),array([[5.4567]],dtype=object),array([[6.4567]], dtype=object)])
>>> np.concatenate(arr).astype(None)
array([[ 2.4567],
[ 3.4567],
[ 4.4567],
[ 5.4567],
[ 6.4567]])
Answered By - Ashwini Chaudhary
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.