9951 explained code solutions for 126 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

.fromstring(

load Nunpy array data from given string and rules

dtype=int

elements type from Numpy types to use when parsing string

sep=','

elements separator to use when parsing string