3000 explained code solutions for 75 technologies

python-numpyConvert string to Numpy array

import numpy as np

str = '1, 2, 3, 4'
a = np.fromstring(str, dtype=int, sep=',')ctrl + c
import numpy as np

load Numpy module for Python

'1, 2, 3, 4'

sample array


load Nunpy array data from given string and rules


elements type from Numpy types to use when parsing string


elements separator to use when parsing string