import numpy as np

a = np.array([['-0.99', '', '0.56', '0.56', '-2.02', '-0.96']])
a[a == ''] = 0.0
a = a.astype(np.float)

Result is:

[[-0.99  0.    0.56  0.56 -2.02 -0.96]]

Your values are floats, not integers. It is not clear if you want a list of lists or a numpy array as your end result. You can easily get a list of lists like this:

a = a.tolist()

Result:

[[-0.99, 0.0, 0.56, 0.56, -2.02, -0.96]]
Answer from abudis on Stack Overflow
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › fromstring()
Python Numpy fromstring() - Convert String to Array | Vultr Docs
November 18, 2024 - The fromstring() function in Python's NumPy library is a powerful tool for converting string data into numerical arrays quickly and efficiently.
Discussions

python - Convert Numpy array with 'n' and 'y' into integer array of 0 and 1 - Data Science Stack Exchange
I have a NumPy array of strings: 'n', 'y', wanna convert it into integer array of 0, 1, how to convert it? More on datascience.stackexchange.com
🌐 datascience.stackexchange.com
January 10, 2020
python - Convert string array to numpy array - Stack Overflow
Releases Keep up-to-date on features ... Stack Internal. ... pythonjavascriptc#reactjsjavaandroidhtmlflutterc++node.jstypescriptcssrphpangularnext.jsspring-bootmachine-learningsqlexceliosazuredocker ... Next You’ll be prompted to create an account to view your personalized homepage. ... Save this question. Show activity on this post. I'm attempting to convert the string '[ 0. 0. 1.]' to a numpy array... More on stackoverflow.com
🌐 stackoverflow.com
python 3.x - How to convert elements type in numpy array from string to int - Stack Overflow
I have a numpy array which looks like this arr = np.array([['1','2','3','4','5','6']]) For the most common way to convert, loops are required like this. for a in arr: for b in a: int(b) More on stackoverflow.com
🌐 stackoverflow.com
python convert string to integer array - Stack Overflow
Using python, I've just made two strings and now want to convert them into an integer array. My two strings are the start and end times of an earth quake and look like this "00:39:59.946000" "0... More on stackoverflow.com
🌐 stackoverflow.com
August 27, 2013
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to convert python numpy array of strings to integers
5 Best Ways to Convert Python NumPy Array of Strings to Integers - Be on the Right Side of Change
February 20, 2024 - The code snippet utilizes a list comprehension to loop through the array of strings, converting each element to an integer before creating a new NumPy array from the list of integers. The np.vectorize() function takes a Python function and applies it to each element of a NumPy array.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.fromstring.html
numpy.fromstring — NumPy v2.2 Manual
If string contains unicode text, the binary mode of fromstring will first encode it into bytes using utf-8, which will not produce sane results. ... Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it.
🌐
Stack Overflow
stackoverflow.com › questions › 61137114 › how-to-convert-elements-type-in-numpy-array-from-string-to-int
python 3.x - How to convert elements type in numpy array from string to int - Stack Overflow
I have a numpy array which looks like this arr = np.array([['1','2','3','4','5','6']]) For the most common way to convert, loops are required like this. for a in arr: for b in a: int(b)
Find elsewhere
🌐
Finxter
blog.finxter.com › 5-ways-to-convert-a-string-list-to-a-numpy-array
5 Ways to Convert a String List to a NumPy Array – Be on the Right Side of Change
July 13, 2023 - The dtype=int argument in np.array() ensures the conversion to integer. You can change the dtype to float or any other type as per your requirement. You can convert a list of strings to a numpy array with a specific shape using the numpy.array() function and then reshape it using the reshape() ...
🌐
Saturn Cloud
saturncloud.io › blog › converting-numpy-array-values-into-integers-a-comprehensive-guide
Converting Numpy Array Values into Integers: A Guide | Saturn Cloud Blog
May 1, 2026 - In this case, the precision of the original floating-point values is compromised during conversion, potentially resulting in unexpected discrepancies in the integer representation. Dealing with non-numeric data during the conversion process presents unique challenges that demand careful consideration. For instance, attempting to convert an array containing strings or other non-numeric types using the astype() method can result in errors. Here’s an illustrative example: import numpy as np mixed_array = np.array([1, 'two', 3]) numeric_array = mixed_array.astype(int)
🌐
Analytics Vidhya
analyticsvidhya.com › home › 6 methods to convert string to int in python
Top 6 Ways to Convert String to Int in Python
May 20, 2025 - Python’s int() function can handle arbitrarily large integers, making it suitable for such scenarios. The choice of conversion method depends on the specific requirements of your program. Consider factors such as performance, input validation, and handling of non-numeric characters when selecting the appropriate method. Converting a string to an integer is a fundamental operation in Python programming.
🌐
GitHub
gist.github.com › tkf › 2276773
Character <-> Int conversion in numpy · GitHub
>>> au = numpy.array(list('ABC'), 'U1') >>> au #doctest: +NORMALIZE_WHITESPACE array([u'A', u'B', u'C'], dtype='<U1') >>> au_as_int = au.view(numpy.uint32) >>> au_as_int array([65, 66, 67], dtype=uint32) >>> # get new copy >>> numpy.array(au_as_int) #doctest: +NORMALIZE_WHITESPACE array([65, 66, 67], dtype=uint32)
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.fromstring.html
numpy.fromstring — NumPy v2.5 Manual
June 22, 2021 - If string contains unicode text, the binary mode of fromstring will first encode it into bytes using utf-8, which will not produce sane results. ... Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it.
🌐
Stack Overflow
stackoverflow.com › questions › 68210530 › converting-string-array-into-int-array-in-python
Converting string array into int array in python - Stack Overflow
July 1, 2021 - Welcome to Stack Overflow, when you read txt from a txt file or any file, the text is stored in a string format. So you would have to do some conversions : Copyimport re def getList(text): someList = [] text = re.sub(r"\s+", "", text, flags=re.UNICODE) for i in text[1:-2].split("),"): print(i) nums = i.split(",") print(nums) someList.append((int(nums[0][1:]),int(nums[1]))) return someList · Pass The text read by your open file fn and pass it to this to get the List you want to pass to the np.array([x],np.int32) fn
🌐
Appdividend
appdividend.com › converting-string-to-numpy-array-in-python
How to Convert a String to Numpy Array in Python
September 7, 2025 - This approach doesn’t require converting strings to lists at any step, making it a faster and more efficient method. import numpy as np string = "11 18 19 21 29" print(string) # Output: 11 18 19 21 29 print(type(string)) # Output: <class 'str'> array = np.fromstring(string, dtype=int, sep=' ') print(array) # Output: [11 18 19 21 29] print(type(array)) # Output: <class 'numpy.ndarray'>
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 174589 › converting-list-of-strings-to-numpy-array-of-integers
python - Converting list of strings to Numpy array ... [SOLVED] | DaniWeb
February 10, 2009 - import numpy qq = [1, 2, 3] ar = numpy.array(qq, dtype='f') print(ar) # [ 1. 2. 3.] It is always easy to run a little test program. It might also be easier to use something like this ... ... So here is the solution I came up with to convert the strings to integers.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.fromstring.html
numpy.fromstring — NumPy v2.1 Manual
The string separating numbers in the data; extra whitespace between elements is also ignored. Deprecated since version 1.14: Passing sep='', the default, is deprecated since it will trigger the deprecated binary mode of this function. This mode interprets string as binary bytes, rather than ASCII text with decimal numbers, an operation which is better spelt frombuffer(string, dtype, count).
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.fromstring.html
numpy.fromstring — NumPy v2.0 Manual
If string contains unicode text, the binary mode of fromstring will first encode it into bytes using utf-8, which will not produce sane results. ... Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it.