当前位置: 首页>>代码示例>>Python>>正文


Python numpy.recfromtxt方法代码示例

本文整理汇总了Python中numpy.recfromtxt方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.recfromtxt方法的具体用法?Python numpy.recfromtxt怎么用?Python numpy.recfromtxt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.recfromtxt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_recfromtxt

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def test_recfromtxt(self):
        #
        data = TextIO('A,B\n0,1\n2,3')
        kwargs = dict(delimiter=",", missing_values="N/A", names=True)
        test = np.recfromtxt(data, **kwargs)
        control = np.array([(0, 1), (2, 3)],
                           dtype=[('A', int), ('B', int)])
        assert_(isinstance(test, np.recarray))
        assert_equal(test, control)
        #
        data = TextIO('A,B\n0,1\n2,N/A')
        test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
        control = ma.array([(0, 1), (2, -1)],
                           mask=[(False, False), (False, True)],
                           dtype=[('A', int), ('B', int)])
        assert_equal(test, control)
        assert_equal(test.mask, control.mask)
        assert_equal(test.A, [0, 2]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_io.py

示例2: test_recfromtxt

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def test_recfromtxt(self):
        #
        data = TextIO('A,B\n0,1\n2,3')
        kwargs = dict(delimiter=",", missing_values="N/A", names=True)
        test = np.recfromtxt(data, **kwargs)
        control = np.array([(0, 1), (2, 3)],
                           dtype=[('A', np.int), ('B', np.int)])
        self.assertTrue(isinstance(test, np.recarray))
        assert_equal(test, control)
        #
        data = TextIO('A,B\n0,1\n2,N/A')
        test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
        control = ma.array([(0, 1), (2, -1)],
                           mask=[(False, False), (False, True)],
                           dtype=[('A', np.int), ('B', np.int)])
        assert_equal(test, control)
        assert_equal(test.mask, control.mask)
        assert_equal(test.A, [0, 2]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:test_io.py

示例3: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    names = ["NABOVE","NBELOW","LOWINC","PERASIAN","PERBLACK","PERHISP",
            "PERMINTE","AVYRSEXP","AVSALK","PERSPENK","PTRATIO","PCTAF",
            "PCTCHRT","PCTYRRND","PERMINTE_AVYRSEXP","PERMINTE_AVSAL",
            "AVYRSEXP_AVSAL","PERSPEN_PTRATIO","PERSPEN_PCTAF","PTRATIO_PCTAF",
            "PERMINTE_AVYRSEXP_AVSAL","PERSPEN_PTRATIO_PCTAF"]
    with open(filepath + '/star98.csv',"rb") as f:
        data = recfromtxt(f, delimiter=",",
                          names=names, skip_header=1, dtype=float)

        # careful now
        nabove = data['NABOVE'].copy()
        nbelow = data['NBELOW'].copy()

        data['NABOVE'] = nbelow # successes
        data['NBELOW'] = nabove - nbelow # now failures

    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:data.py

示例4: _getdiaginfo

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _getdiaginfo(self, path):
        dpath = os.path.join(os.path.dirname(path), 'diaginfo.dat')
        if not os.path.exists(dpath):
            dpath = 'diaginfo.dat'
        self._ddata = np.recfromtxt(dpath, dtype=None, comments='#', names=[
                                    'offset', 'category', 'comment'],
                                    delimiter=[9, 40, 100], autostrip=True)

# OFFSET    (I8 )  Constant to add to tracer numbers in order to distinguish
#                  for the given diagnostic category, as stored in file
#                  "tracerinfo.dat".  OFFSET may be up to 8 digits long.
#  --       (1X )  1-character spacer
# CATEGORY  (A40)  Category name for CTM diagnostics. NOTE: The category name
#                  can be up to 40 chars long, but historically the GEOS-CHEM
#                  and GISS models have used an 8-character category name.
# COMMENT   (A  )  Descriptive comment string
#
#  --       (1X )  1-character spacer 
开发者ID:barronh,项目名称:pseudonetcdf,代码行数:20,代码来源:_newbpch.py

示例5: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def __init__(self, path):
        # import pdb; pdb.set_trace()
        self._data = np.recfromtxt(
            path, names=names, delimiter=delimiter, comments='*')
        self.createDimension('receptor', self._data.size)
        self.createDimension('StrLen', StrLen)
        for k, u in zip(names, units):
            if k in 'dum1 dum2 dum3'.split():
                continue
            vals = self._data[k]
            dt = vals.dtype.char
            dims = ('receptor',)
            if dt == 'S':
                vals = np.char.ljust(np.char.strip(vals), StrLen).view(
                    'S1').reshape(-1, StrLen)
                dims = ('receptor', 'StrLen')
                dt = 'S1'
            var = self.createVariable(k, dt, dims)
            var.units = u
            var[:] = vals 
开发者ID:barronh,项目名称:pseudonetcdf,代码行数:22,代码来源:_aermod_plotfile.py

示例6: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    with open(filepath + '/heart.csv', 'rb') as f:
        data = np.recfromtxt(f, delimiter=",", names = True, dtype=float)
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:data.py

示例7: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    with open(filepath + '/co2.csv', 'rb') as f:
        data = np.recfromtxt(f, delimiter=",", names=True, dtype=['a8', float])
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:data.py

示例8: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    with open(filepath + '/nile.csv', 'rb') as f:
        data = recfromtxt(f, delimiter=",",
                          names=True, dtype=float)
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:data.py

示例9: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    with open(filepath + '/DatasetName.csv', 'rb') as fd:
        data = np.recfromtxt(fd, delimiter=",", names=True, dtype=float)
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:template_data.py

示例10: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    with open(filepath + '/copper.csv', 'rb') as f:
        data = recfromtxt(f, delimiter=",",
                          names=True, dtype=float, usecols=(1,2,3,4,5,6))
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:data.py

示例11: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    with open(filepath + '/cancer.csv', 'rb') as f:
        data = np.recfromtxt(f, delimiter=",", names=True, dtype=float)
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:data.py

示例12: _get_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import recfromtxt [as 别名]
def _get_data():
    filepath = dirname(abspath(__file__))
    with open(filepath + '/modechoice.csv', 'rb') as f:
        data = np.recfromtxt(f, delimiter=";", names=True, dtype=float)
    return data 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:data.py


注:本文中的numpy.recfromtxt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。