bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / fromstring
built-in
numpy:fromstring
Signature
fromstring ( string , dtype = <class 'float'> , count = -1 , * , sep , like = None ) Summary
A new 1-D array initialized from text data in a string.
Parameters
string: strA string containing the data.
dtype: data-type, optionalThe data type of the array; default: numpy.float64. For binary input data, the data must be in exactly this format. Most builtin numeric types are supported and extension types may be supported.
count: int, optionalRead this number of
dtypeelements from the data. If this is negative (the default), the count will be determined from the length of the data.sep: str, optionalThe string separating numbers in the data; extra whitespace between elements is also ignored.
like: array_like, optionalReference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as
likesupports the__array_function__protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.
Returns
arr: ndarrayThe constructed array.
Raises
: ValueErrorIf the string is not the correct size to satisfy the requested
dtypeandcount.
Examples
import numpy as np np.fromstring('1 2', dtype=int, sep=' ') np.fromstring('1, 2', dtype=int, sep=',')✓
See also
- frombuffer
- fromfile
- fromiter
Aliases
-
numpy.fromstring