Python numpy.recfromtxt() Examples
The following are 30
code examples of numpy.recfromtxt().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: test_io.py From keras-lambda with MIT License | 6 votes |
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])
Example #2
Source File: test_io.py From vnpy_crypto with MIT License | 6 votes |
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])
Example #3
Source File: data.py From vnpy_crypto with MIT License | 6 votes |
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
Example #4
Source File: test_io.py From auto-alt-text-lambda-api with MIT License | 6 votes |
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])
Example #5
Source File: test_io.py From lambda-packs with MIT License | 6 votes |
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])
Example #6
Source File: test_io.py From Computable with MIT License | 6 votes |
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])
Example #7
Source File: test_io.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
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])
Example #8
Source File: test_io.py From GraphicDesignPatternByPython with MIT License | 6 votes |
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])
Example #9
Source File: test_io.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
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])
Example #10
Source File: test_io.py From pySINDy with MIT License | 6 votes |
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])
Example #11
Source File: _newbpch.py From pseudonetcdf with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #12
Source File: _aermod_plotfile.py From pseudonetcdf with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #13
Source File: test_io.py From ImageFusion with MIT License | 6 votes |
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])
Example #14
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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
Example #15
Source File: test_io.py From elasticintel with GNU General Public License v3.0 | 6 votes |
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])
Example #16
Source File: test_io.py From recruit with Apache License 2.0 | 6 votes |
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])
Example #17
Source File: test_io.py From coffeegrindsize with MIT License | 6 votes |
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])
Example #18
Source File: test_io.py From mxnet-lambda with Apache License 2.0 | 6 votes |
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])
Example #19
Source File: test_io.py From twitter-stock-recommendation with MIT License | 6 votes |
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])
Example #20
Source File: test_io.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
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])
Example #21
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) with open(filepath + "/ccard.csv", 'rb') as f: data = recfromtxt(f, delimiter=",", names=True, dtype=float) return data
Example #22
Source File: test_io.py From vnpy_crypto with MIT License | 5 votes |
def test_recfromtxt(self): with temppath(suffix='.txt') as path: path = Path(path) with path.open('w') as f: f.write(u'A,B\n0,1\n2,3') kwargs = dict(delimiter=",", missing_values="N/A", names=True) test = np.recfromtxt(path, **kwargs) control = np.array([(0, 1), (2, 3)], dtype=[('A', int), ('B', int)]) assert_(isinstance(test, np.recarray)) assert_equal(test, control)
Example #23
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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
Example #24
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) with open(filepath + '/anes96.csv', "rb") as f: data = recfromtxt(f, delimiter="\t", names=True, dtype=float) logpopul = log(data['popul'] + .1) data = nprf.append_fields(data, 'logpopul', logpopul, usemask=False, asrecarray=True) return data
Example #25
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv ##### with open(filepath + '/engel.csv', 'rb') as f: data = np.recfromtxt(f, delimiter=",", names = True, dtype=float) return data
Example #26
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) with open(filepath + '/sunspots.csv', 'rb') as f: data = recfromtxt(f, delimiter=",", names=True, dtype=float) return data
Example #27
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) with open(filepath + '/stackloss.csv',"rb") as f: data = recfromtxt(f, delimiter=",", names=True, dtype=float) return data
Example #28
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv ##### with open(filepath + '/fair.csv', 'rb') as f: data = np.recfromtxt(f, delimiter=",", names=True, dtype=float) return data
Example #29
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): filepath = dirname(abspath(__file__)) with open(filepath + '/macrodata.csv', 'rb') as f: data = recfromtxt(f, delimiter=",", names=True, dtype=float) return data
Example #30
Source File: data.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_data(): with open(PATH, "rb") as f: data = recfromtxt(f, delimiter=",", names=True, dtype=float) return data