Issue
I have a NumPy list (Distances). When I print it, the result is:
array([[ 1. ],
[600. ],
[456.03971033],
[294.94188261],
[286.47232436],
[ 92.08606785]])
However, I want to get any specific element of this list as a float number without any brackets, array, and '' sign. Note that I don't want to print it, I need to have the number in another variable like this:
element1 = Distance[0]
Result is: array([1.])
But I want it to be just: 1.
Solution
You can first flatten the array to make it one dimensional:
flatdistance = Distance.flatten()
element1 = flatdistance[0]
Answered By - Matt Pitkin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.