list may help you do that.

import numpy as np

mystr = "100110"
print np.array(list(mystr))
# ['1' '0' '0' '1' '1' '0']

If you want to get numbers instead of string:

print np.array(list(mystr), dtype=int)
# [1 0 0 1 1 0]
Answer from dragon2fly 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 - Convert the string to a NumPy array using fromstring() specifying the data type and delimiter.
Discussions

vector - Python numpy: Convert string in to numpy array - Stack Overflow
I have following String that I have put together: v1fColor = '2,4,14,5,0,0,0,0,0,0,0,0,0,0,12,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,6,0,0,0,0,1,0,0,0,0,0,0,0,0,0,20,9,0,0,0,2,2,0,0,0,0,0,0,0,0,0,13,6,0... More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 23, 2016
convert string representation of array to numpy array in python - Stack Overflow
If so, then the answer is no, you can't get a numpy array from literal_eval. From the python documentation of ast.literal_eval(node_or_string): "The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None." If what you really want is a convenient way to convert ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - convert string to 2d numpy array - Stack Overflow
I am trying to convert 'b' (a string in which the column entries are separated by one delimiter and the the rows are separated by another delimiter) to 'a' (a 2d numpy array), like: b='191.250\t0.... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Convert string to numpy array of strings - Stack Overflow
I have a string of data data = "1,Hey,234,4456,789" that I want to convert into a numpy array. Whenever I try the code numpy.fromstring(data,dtype=str,sep=","), I get the error "ValueError: zero-valued itemsize". What is the correct way to use this function so that it works as intended? More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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'>
๐ŸŒ
w3resource
w3resource.com โ€บ numpy โ€บ array-creation โ€บ fromstring.php
NumPy: numpy.fromstring() function - w3resource
April 21, 2026 - Example: Creating an array from a string using np.fromstring() >>> import numpy as np >>> np.fromstring('3 5', dtype=int, sep=' ') array([3, 5])
Find elsewhere
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ convert different python data structures to numpy array?
Convert different Python Data structures to Numpy Array? - Scaler Topics
May 4, 2023 - The numpy.fromstring() method creates a NumPy array from text data in a string. ... Over here, the string parameter represents a string holding the data, and the sep argument represents a string dividing the data. Let us better understand this by using an illustration. ... To convert data from a Dictionary format to a NumPy array format, we utilize np.array() and a list type conversion...
๐ŸŒ
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() ...
๐ŸŒ
Codegive
codegive.com โ€บ blog โ€บ numpy_string_to_array.php
NumPy String to Array: A Comprehensive Tutorial
Handling Errors During Conversion: Always anticipate non-convertible strings when converting to numeric types. Use try-except blocks, np.nan placeholders, or filtering to prevent ValueError exceptions. Performance: For very large datasets, Python list comprehensions can be slower than vectorized NumPy or Pandas operations. If your strings are already in a NumPy array and you need to apply string operations, np.char is generally faster than looping through a Python list.
๐ŸŒ
PyTutorial
pytutorial.com โ€บ python-string-to-array-conversion-guide
PyTutorial | Python String to Array Conversion Guide
August 15, 2026 - If you work with numerical data, you might need a NumPy array. The numpy.array() function can convert a string to an array of characters or numbers.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-ways-to-convert-array-of-strings-to-array-of-floats
Python | Ways to convert array of strings to array of floats - GeeksforGeeks
July 28, 2023 - Here is the approach to convert an array of strings from Python to an array float using astype(). It is used to change the datatype of a series. if a column could be imported as a string but to do operations we have to convert it into a float, ...
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.1 โ€บ user โ€บ basics.strings.html
Working with Arrays of Strings And Bytes โ€” NumPy v2.1 Manual
Also note that unlike fixed-width strings and most other NumPy data types, StringDType does not store the string data in the โ€œmainโ€ ndarray data buffer. Instead, the array buffer is used to store metadata about where the string data are stored in memory.
Top answer
1 of 9
55

**Update (NumPy 1.19+):** Note that `.tostring()` is deprecated since NumPy 1.19. Use `.tobytes()` instead, which has identical behavior.

You can use the fromstring() method for this:

arr = np.array([1, 2, 3, 4, 5, 6])
ts = arr.tostring()
print(np.fromstring(ts, dtype=int))

>>> [1 2 3 4 5 6]

Sorry for the short answer, not enough points for commenting. Remember to state the data types or you'll end up in a world of pain.

Note on fromstring from numpy 1.14 onwards:

sep : str, optional

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). If string contains unicode text, the binary mode of fromstring will first encode it into bytes using either utf-8 (python 3) or the default encoding (python 2), neither of which produce sane results.

2 of 9
28

If you use tostring you lose information on both shape and data type:

>>> import numpy as np
>>> a = np.arange(12).reshape(3, 4)
>>> a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])
>>> s = a.tostring()
>>> aa = np.fromstring(a)
>>> aa
array([  0.00000000e+000,   4.94065646e-324,   9.88131292e-324,
         1.48219694e-323,   1.97626258e-323,   2.47032823e-323,
         2.96439388e-323,   3.45845952e-323,   3.95252517e-323,
         4.44659081e-323,   4.94065646e-323,   5.43472210e-323])
>>> aa = np.fromstring(a, dtype=int)
>>> aa
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11])
>>> aa = np.fromstring(a, dtype=int).reshape(3, 4)
>>> aa
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])

This means you have to send the metadata along with the data to the recipient. To exchange auto-consistent objects, try cPickle:

>>> import cPickle
>>> s = cPickle.dumps(a)
>>> cPickle.loads(s)
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])