Well, if you're reading the data in as a list, just do np.array(map(float, list_of_strings)) (or equivalently, use a list comprehension). (In Python 3, you'll need to call list on the map return value if you use map, since map returns an iterator now.)

However, if it's already a numpy array of strings, there's a better way. Use astype().

import numpy as np
x = np.array(['1.1', '2.2', '3.3'])
y = x.astype(np.float)
Answer from Joe Kington on Stack Overflow
🌐
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 - Explanation: Here, a string array a is converted to a float array res using astype(float), creating a new array without modifying the original.
Discussions

Is there a way to define a float array in Python? - Stack Overflow
For my astronomy homework, I need to simulate the elliptical orbit of a planet around a sun. To do this, I need to use a for loop to repeatedly calculate the motion of the planet. However, every ti... More on stackoverflow.com
🌐 stackoverflow.com
Converting an int in an Array to float
If it is an array of ints, you won’t be able to “convert” one in that array to a float since the array only accepts ints. You could still get the score as a float by doing Float score = scores[i].score; More on reddit.com
🌐 r/Unity3D
5
0
September 12, 2022
Converting str array to float array
What does the rest of the file look like? Looping over lines in your file should give you strings like “[1,2,3,4,5]” which you can parse by stripping brackets, splitting on commas, and mapping int or float to each thing. More on reddit.com
🌐 r/learnpython
12
0
April 15, 2021
Normalizing array of floats
Take a look at the first answer to this StackOverflow post, it might help you https://stackoverflow.com/questions/1735025/how-to-normalize-a-numpy-array-to-within-a-certain-range It is pretty much what JadeSerpant is suggesting though. I don't know enough about WAVs, but you'll have been given a range of floating point values from a-->b (probably with a=0), and you want to map them to the range of integers (-32768 --> +32767), which are the limits for a signed 16 bit number. So you need to get your numbers and do some maths to shift and rescale your range to fit. (You can think of it as the integers (0 --> 65,535) shifted down by (65,535+1)/2=32768 if that helps) Assuming we want the mid-point of your range a --> b to map to exactly 0 after conversion (silence in our WAV), then we want something like: midpoint = (a+b)/2 extent = (b-a) # newsignal = (signal-midpoint)/(0.5*extent) # Gives range of floating point values from a minimum of -1 to a maximum of +1. newsignal2 = 32767*(signal-midpoint)/(0.5*extent) # Gives range of floating point values from a minimum of -32767 to a maximum of +32767. Note that I multiply by 32767 and not 32768. Otherwise, the +1 would become 32768, which would be too big. It is easier to see that this works in the simpler case where a=0, i.e., if the signal is from 0 --> b. midpoint = b/2 extent = b # newsignal = (signal-b/2)/(0.5*b) # Any values of 0 become (-b/2)/(0.5b) = -1, any value of b become (b-b/2)/(0.5b) = +1 newsignal2 = 32767*(signal-b/2)/(0.5*b) # Gives range of floating point values from a minimum of -32767 to a maximum of +32767. If you did the scaling and shifting differently to occupy the whole int16 range fully, then the midpoint of the signal cannot be exactly 0 in the wav file. While I'm not aware of a clever numpy function to do all this for you, you are already relying on using numpy arrays for the above code to work. Doing this with just Python would be harder. Before writing your data to a file, you will also likely need to round to the nearest integer and cast the values of the array to the int16 integer data type. As casting does a crude truncating rounding for you, you can probably just do: newsignal3 = newsignal2.astype('int16') and be fine, but you'll have to take a look and find out. More on reddit.com
🌐 r/learnpython
4
1
September 29, 2022
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › array › astype
Python Numpy array astype() - Convert Data Type | Vultr Docs
November 8, 2024 - Such conversion can reduce memory usage, important for handling large datasets. The astype() function in NumPy makes it possible to convert the data type of array elements seamlessly.
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-7.php
NumPy: Array converted to a float type - w3resource
August 29, 2025 - Write a NumPy program to convert an array to a floating type. ... # Importing the NumPy library with an alias 'np' import numpy as np # Defining a Python list 'a' containing integers a = [1, 2, 3, 4] # Printing the original array 'a' print("Original array") print(a) # Converting the array 'a' to a NumPy array of type float using asfarray() x = np.asfarray(a) # Printing the array 'x' after converting to a float type print("Array converted to a float type:") print(x)
🌐
IncludeHelp
includehelp.com › python › convert-list-or-numpy-array-of-single-element-to-float.aspx
Python - Convert list or NumPy array of single element to float
December 23, 2023 - # Import numpy import numpy as np # Creating a numpy array arr = np.array([4]) # Display original array print("Original Array:\n", arr, "\n") # Converting to float res = float(arr) # Display result print("Result:\n", res) ''' # YOU CAN ALSO USE THIS...
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-convert-numpy-array-to-list
Convert NumPy Array to List in Python Easily | DigitalOcean
April 19, 2025 - We also covered the process of converting a 2D NumPy array to a list of lists and flattening a NumPy array to a list. If you’re interested in learning more about NumPy, check out the following tutorials: ... Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases. ... Java and Python Developer for 20+ years, Open Source Enthusiast, Founder of https://www.askpython.com/, https://www.linuxfordevices.com/, and JournalDev.com (acquired by DigitalOcean).
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-ways-to-convert-array-of-strings-to-array-of-floats
Python | Ways to convert array of strings to array of floats - GeeksforGeeks
July 11, 2025 - Here is the approach to convert ... array to store the converted floats. Loop through each element of the input array and convert the current element to a float using the float() function....
🌐
NumPy
numpy.org › devdocs › user › basics.types.html
Data types — NumPy v2.5.dev0 Manual
There are some exceptions, such ... Python scalar. Generally, problems are easily fixed by explicitly converting array scalars to Python scalars, using the corresponding Python type function (e.g., int, float, complex, str)....
Find elsewhere
🌐
W3Schools
w3schools.com › python › numpy › numpy_data_types.asp
NumPy Data Types
A non integer string like 'a' can ... · The best way to change the data type of an existing array, is to make a copy of the array with the astype() method....
🌐
Finxter
blog.finxter.com › 5-best-ways-to-convert-a-python-float-to-array
5 Best Ways to Convert a Python Float to Array – Be on the Right Side of Change
In this code, the struct.pack() function is used to convert the float into its binary representation. Then, unpack() is used to transform that binary data back into a float, which is turned into a list. A snappy one-liner using list comprehension can encapsulate the conversion of a float to an array in Python.
🌐
NumPy
numpy.org › doc › 2.2 › user › basics.types.html
Data types — NumPy v2.2 Manual
There are some exceptions, such ... Python scalar. Generally, problems are easily fixed by explicitly converting array scalars to Python scalars, using the corresponding Python type function (e.g., int, float, complex, str)....
🌐
Java2Blog
java2blog.com › home › python › python array › convert float array to int array in python
Convert float array to int array in Python - Java2Blog
November 11, 2021 - We can create arrays of any one of the data types provided in Python. In Python, the float values represent all the numbers containing a decimal point. The int data type represents integers. This tutorial demonstrates the different ways to convert an array of floating-point numbers to an array of integers in Python.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-convert-numpy-int-to-float-with-a-separate-numpy-array-a-comprehensive-guide-for-data-scientists
How to Convert Numpy Int to Float with a Separate Numpy Array: A Guide for Data Scientists | Saturn Cloud Blog
October 4, 2023 - This function creates a copy of the array, and converts the data type. ⚠ This code is experimental content and was generated by AI. Please refer to this code as experimental only since we cannot currently guarantee its validity · float_array = int_array.astype('float') print(float_array)
🌐
Delft Stack
delftstack.com › home › howto › numpy › numpy convert string array to float array
How to Convert String to Float in NumPy | Delft Stack
February 2, 2024 - ['1.000' '1.235' '0.000125' '2' ... refer to its official documentation · asarray() is a NumPy function that converts the input array to a NumPy array of a specified type....