The tolist() method should do what you want. If you have a numpy array, just call tolist():

In [17]: a
Out[17]: 
array([ 0.        ,  0.14285714,  0.28571429,  0.42857143,  0.57142857,
        0.71428571,  0.85714286,  1.        ,  1.14285714,  1.28571429,
        1.42857143,  1.57142857,  1.71428571,  1.85714286,  2.        ])

In [18]: a.dtype
Out[18]: dtype('float64')

In [19]: b = a.tolist()

In [20]: b
Out[20]: 
[0.0,
 0.14285714285714285,
 0.2857142857142857,
 0.42857142857142855,
 0.5714285714285714,
 0.7142857142857142,
 0.8571428571428571,
 1.0,
 1.1428571428571428,
 1.2857142857142856,
 1.4285714285714284,
 1.5714285714285714,
 1.7142857142857142,
 1.857142857142857,
 2.0]

In [21]: type(b)
Out[21]: list

In [22]: type(b[0])
Out[22]: float

If, in fact, you really have python list of numpy.float64 objects, then @Alexander's answer is great, or you could convert the list to an array and then use the tolist() method. E.g.

In [46]: c
Out[46]: 
[0.0,
 0.33333333333333331,
 0.66666666666666663,
 1.0,
 1.3333333333333333,
 1.6666666666666665,
 2.0]

In [47]: type(c)
Out[47]: list

In [48]: type(c[0])
Out[48]: numpy.float64

@Alexander's suggestion, a list comprehension:

In [49]: [float(v) for v in c]
Out[49]: 
[0.0,
 0.3333333333333333,
 0.6666666666666666,
 1.0,
 1.3333333333333333,
 1.6666666666666665,
 2.0]

Or, convert to an array and then use the tolist() method.

In [50]: np.array(c).tolist()
Out[50]: 
[0.0,
 0.3333333333333333,
 0.6666666666666666,
 1.0,
 1.3333333333333333,
 1.6666666666666665,
 2.0]

If you are concerned with the speed, here's a comparison. The input, x, is a python list of numpy.float64 objects:

In [8]: type(x)
Out[8]: list

In [9]: len(x)
Out[9]: 1000

In [10]: type(x[0])
Out[10]: numpy.float64

Timing for the list comprehension:

In [11]: %timeit list1 = [float(v) for v in x]
10000 loops, best of 3: 109 µs per loop

Timing for conversion to numpy array and then tolist():

In [12]: %timeit list2 = np.array(x).tolist()
10000 loops, best of 3: 70.5 µs per loop

So it is faster to convert the list to an array and then call tolist().

Answer from Warren Weckesser on Stack Overflow
Top answer
1 of 3
31

The tolist() method should do what you want. If you have a numpy array, just call tolist():

In [17]: a
Out[17]: 
array([ 0.        ,  0.14285714,  0.28571429,  0.42857143,  0.57142857,
        0.71428571,  0.85714286,  1.        ,  1.14285714,  1.28571429,
        1.42857143,  1.57142857,  1.71428571,  1.85714286,  2.        ])

In [18]: a.dtype
Out[18]: dtype('float64')

In [19]: b = a.tolist()

In [20]: b
Out[20]: 
[0.0,
 0.14285714285714285,
 0.2857142857142857,
 0.42857142857142855,
 0.5714285714285714,
 0.7142857142857142,
 0.8571428571428571,
 1.0,
 1.1428571428571428,
 1.2857142857142856,
 1.4285714285714284,
 1.5714285714285714,
 1.7142857142857142,
 1.857142857142857,
 2.0]

In [21]: type(b)
Out[21]: list

In [22]: type(b[0])
Out[22]: float

If, in fact, you really have python list of numpy.float64 objects, then @Alexander's answer is great, or you could convert the list to an array and then use the tolist() method. E.g.

In [46]: c
Out[46]: 
[0.0,
 0.33333333333333331,
 0.66666666666666663,
 1.0,
 1.3333333333333333,
 1.6666666666666665,
 2.0]

In [47]: type(c)
Out[47]: list

In [48]: type(c[0])
Out[48]: numpy.float64

@Alexander's suggestion, a list comprehension:

In [49]: [float(v) for v in c]
Out[49]: 
[0.0,
 0.3333333333333333,
 0.6666666666666666,
 1.0,
 1.3333333333333333,
 1.6666666666666665,
 2.0]

Or, convert to an array and then use the tolist() method.

In [50]: np.array(c).tolist()
Out[50]: 
[0.0,
 0.3333333333333333,
 0.6666666666666666,
 1.0,
 1.3333333333333333,
 1.6666666666666665,
 2.0]

If you are concerned with the speed, here's a comparison. The input, x, is a python list of numpy.float64 objects:

In [8]: type(x)
Out[8]: list

In [9]: len(x)
Out[9]: 1000

In [10]: type(x[0])
Out[10]: numpy.float64

Timing for the list comprehension:

In [11]: %timeit list1 = [float(v) for v in x]
10000 loops, best of 3: 109 µs per loop

Timing for conversion to numpy array and then tolist():

In [12]: %timeit list2 = np.array(x).tolist()
10000 loops, best of 3: 70.5 µs per loop

So it is faster to convert the list to an array and then call tolist().

2 of 3
11

You could use a list comprehension:

floats = [float(np_float) for np_float in np_float_list]
🌐
GeeksforGeeks
geeksforgeeks.org › python › using-numpy-to-convert-array-elements-to-float-type
Using NumPy to Convert Array Elements to Float Type - GeeksforGeeks
July 15, 2025 - This approach reuses the astype() method like before, but here you overwrite the original array with the converted one. It’s a form of in-place reassignment, not true in-place conversion which NumPy doesn’t support due to fixed data types .
Discussions

numpy.float64 is not converted to float
In the code below, I would expect the numpy.float64 to be converted to a float by the Foo pydantic object. More on github.com
🌐 github.com
6
August 28, 2020
Preventing numpy from converting float type to numpy.int64 type
Numpy arrays have a defined data type. eta_hat is an array of dtype int64, because that's how you initialized it in the first place: as the docs say, if no type is given explicitly then "the type will be determined as the minimum type required to hold the objects in the sequence". So the solution is to explicitly make it an array of floats: eta_hat = numpy.array( [ [0], [0], [0] ], dtype=float) More on reddit.com
🌐 r/learnpython
3
1
April 3, 2023
`np.float64` is not accepted as `float` under static type checks
Some of the built-in scalar types inherit from the corresponding Python types. However, this fact does not seem to be exposed by the numpy type stubs. # Python version 3.8.10, numpy version 1.23.0 import numpy as np x = np.float64(1.0) p... More on github.com
🌐 github.com
3
July 2, 2022
python - Convert numpy array type and values from Float64 to Float32 - Stack Overflow
The problem is that you do not do any type conversion of the numpy array. You calculate a float32 variable and put it as an entry into a float64 numpy array. More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 3
8

Yes, actually when you use Python's native float to specify the dtype for an array , numpy converts it to float64. As given in documentation -

Note that, above, we use the Python float object as a dtype. NumPy knows that int refers to np.int_, bool means np.bool_ , that float is np.float_ and complex is np.complex_. The other data-types do not have Python equivalents.

And -

float_ - Shorthand for float64.

This is why even though you use float to convert the whole array to float , it still uses np.float64.

According to the requirement from the other question , the best solution would be converting to normal float object after taking each scalar value as -

float(new_array[0])

A solution that I could think of is to create a subclass for float and use that for casting (though to me it looks bad). But I would prefer the previous solution over this if possible. Example -

In [20]: import numpy as np

In [21]: na = np.array([1., 2., 3.])

In [22]: na = np.array([1., 2., 3., np.inf, np.inf])

In [23]: type(na[-1])
Out[23]: numpy.float64

In [24]: na[-1] - na[-2]
C:\Anaconda3\Scripts\ipython-script.py:1: RuntimeWarning: invalid value encountered in double_scalars
  if __name__ == '__main__':
Out[24]: nan

In [25]: class x(float):
   ....:     pass
   ....:

In [26]: na_new = na.astype(x)


In [28]: type(na_new[-1])
Out[28]: float                           #No idea why its showing float, I would have thought it would show '__main__.x' .

In [29]: na_new[-1] - na_new[-2]
Out[29]: nan

In [30]: na_new
Out[30]: array([1.0, 2.0, 3.0, inf, inf], dtype=object)
2 of 3
3

You can create an anonymous type float like this

>>> new_array = my_array.astype(type('float', (float,), {}))
>>> type(new_array[0])
<type 'float'>
🌐
w3resource
w3resource.com › python-exercises › numpy › basic › numpy-basic-exercise-41.php
NumPy: Convert numpy dtypes to native python types - w3resource
August 28, 2025 - This problem involves writing a NumPy program to convert NumPy data types (dtypes) to native Python types. The task requires using NumPy's type conversion functions to transform NumPy-specific data types, such as numpy.int32 or numpy.float32, into their equivalent native Python types, like int or float.
🌐
Medium
medium.com › @amit25173 › understanding-numpy-float64-a300ac9e096a
Understanding numpy.float64. If you think you need to spend $2,000… | by Amit Yadav | Medium
February 8, 2025 - You might be wondering: “Can I convert an existing array into float64?” · Absolutely! You can convert any NumPy array (or even a regular list) into float64 using the astype() method.
🌐
NumPy
numpy.org › devdocs › user › basics.types.html
Data types — NumPy v2.5.dev0 Manual
A basic numerical type name combined with a numeric bitsize defines a concrete type. The bitsize is the number of bits that are needed to represent a single value in memory. For example, numpy.float64 is a 64 bit floating point data type. Some types, such as numpy.int_ and numpy.intp, have ...
Find elsewhere
🌐
GitHub
github.com › samuelcolvin › pydantic › issues › 1879
numpy.float64 is not converted to float · Issue #1879 · pydantic/pydantic
August 28, 2020 - In the code below, I would expect the numpy.float64 to be converted to a float by the Foo pydantic object.
Author   dewolfarno
🌐
W3Schools
w3schools.com › python › numpy › numpy_data_types.asp
NumPy Data Types
NumPy has some extra data types, and refer to data types with one character, like i for integers, u for unsigned integers etc.
🌐
YouTube
youtube.com › codetube
Convert list of numpy float64 to float in Python quickly - YouTube
In Python, you might need to convert a list of numpy.float64 elements to regular Python float type for various purposes. This tutorial will guide you through...
Published   November 4, 2023
Views   73
🌐
Reddit
reddit.com › r/learnpython › preventing numpy from converting float type to numpy.int64 type
r/learnpython on Reddit: Preventing numpy from converting float type to numpy.int64 type
April 3, 2023 -

So I have 3-tuple of only float types, let's call it eta.

I also have a class attribute eta_hat which is initialized as numpy.array( [ [0], [0], [0] ] ), the idea it being a column vector.

My goal is to make the values of eta_hat the values of eta. However, the piece of code

self.eta_hat[0][0], self.eta_hat[1][0], self.eta_hat[2][0] = eta[0], eta[1], eta[2]

converts eta[x] from float to numpy.int64 in self.eta_hat[x][0]. I do not understand how numpy handles these, and would love an explenation on how I could fix this problem. Thanks!

🌐
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.4 Manual
A basic numerical type name combined with a numeric bitsize defines a concrete type. The bitsize is the number of bits that are needed to represent a single value in memory. For example, numpy.float64 is a 64 bit floating point data type. Some types, such as numpy.int_ and numpy.intp, have ...
🌐
GitHub
github.com › numpy › numpy › issues › 21906
`np.float64` is not accepted as `float` under static type checks · Issue #21906 · numpy/numpy
July 2, 2022 - However, this fact does not seem to be exposed by the numpy type stubs. # Python version 3.8.10, numpy version 1.23.0 import numpy as np x = np.float64(1.0) print(f"x={x} of type={type(x)} is float: {isinstance(x, float)}") # x=1.0 of type=<class 'numpy.float64'> is float: True def f(a: float) -> float: return a f(x) """ pyright 1.1.256: error: Argument of type "float64" cannot be assigned to parameter "a" of type "float" in function "f" "float64" is incompatible with "float" (reportGeneralTypeIssues) mypy 0.961: error: Argument 1 to "f" has incompatible type "floating[_64Bit]"; expected "float" """ Replacing np.float64 with np.float_ or np.double does not help.
Author   0xjc
🌐
NumPy
numpy.org › doc › 1.22 › user › basics.types.html
Data types — NumPy v1.22 Manual
If 64-bit integers are still too small the result may be cast to a floating point number. Floating point numbers offer a larger, but inexact, range of possible values. >>> np.power(100, 100, dtype=np.int64) # Incorrect even with 64-bit int 0 >>> np.power(100, 100, dtype=np.float64) 1e+200
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.astype.html
numpy.ndarray.astype — NumPy v2.4 Manual
June 22, 2021 - ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-54731 › Unexpected-type-warning-when-adding-numpyfloat64-variables-together
Unexpected type warning when adding numpy.float64 ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Quora
quora.com › What-is-np-float32-and-np-float64-in-numpy-in-simple-terms
What is np.float32 and np.float64 in numpy in simple terms? - Quora
Answer (1 of 2): np.float32 - It means that each value in the numpy array would be a float of size 32 bits. np.float64- It means that each value in the numpy array would be a float of size 64.
🌐
YouTube
youtube.com › watch
PYTHON : Convert numpy array type and values from Float64 ...
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.