當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。