4

I want to convert a 1D numpy array to a simple float (no array). How is that done? Here is my current code with the variable 'acc'.

print type(acc)
print acc.shape

>>> <type 'numpy.ndarray'>
>>> (1,)

1 Answer 1

6

Can't you just do:

float(acc)

To make it a float? Seems to be working here:

a = np.array([1])
print a.shape
print type(a)
print float(a)

yields

(1,)
<type 'numpy.ndarray'>
1.0
Sign up to request clarification or add additional context in comments.

1 Comment

There are situations where this doesn't work. Like mine...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.