标签:tput returns like tor github not sci dict des
Load data from a text file.
Each row in the text file must have the same number of values.
Parameters: |
fname : file or str
dtype : data-type, optional
comments : str or sequence, optional
delimiter : str, optional
converters : dict, optional
skiprows : int, optional
usecols : sequence, optional
unpack : bool, optional
ndmin : int, optional
|
---|---|
Returns: |
out : ndarray
|
See also
Notes
This function aims to be a fast reader for simply formatted files. The genfromtxt function provides more sophisticated handling of, e.g., lines with missing values.
New in version 1.10.0.
The strings produced by the Python float.hex method can be used as input for floats.
Examples
>>> from io import StringIO # StringIO behaves like a file object
>>> c = StringIO("0 1\n2 3")
>>> np.loadtxt(c)
array([[ 0., 1.],
[ 2., 3.]])
>>> d = StringIO("M 21 72\nF 35 58")
>>> np.loadtxt(d, dtype={‘names‘: (‘gender‘, ‘age‘, ‘weight‘),
... ‘formats‘: (‘S1‘, ‘i4‘, ‘f4‘)})
array([(‘M‘, 21, 72.0), (‘F‘, 35, 58.0)],
dtype=[(‘gender‘, ‘|S1‘), (‘age‘, ‘<i4‘), (‘weight‘, ‘<f4‘)])
>>> c = StringIO("1,0,2\n3,0,4")
>>> x, y = np.loadtxt(c, delimiter=‘,‘, usecols=(0, 2), unpack=True)
>>> x
array([ 1., 3.])
>>> y
array([ 2., 4.])
以上为转载!
标签:tput returns like tor github not sci dict des
原文地址:https://www.cnblogs.com/master-road/p/10451169.html