Python matplotlib.cbook.align_iterators() Examples
The following are 8
code examples of matplotlib.cbook.align_iterators().
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
matplotlib.cbook
, or try the search function
.
Example #1
Source File: mlab.py From Computable with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + map(extract, row)) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + map(extract, row)) if postfixes is None: postfixes = ['%d'%i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #2
Source File: mlab.py From matplotlib-4-abaqus with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + map(extract, row)) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + map(extract, row)) if postfixes is None: postfixes = ['%d'%i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #3
Source File: mlab.py From neural-network-animation with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + list(map(extract, row))) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + list(map(extract, row))) if postfixes is None: postfixes = ['%d'%i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #4
Source File: mlab.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + list(map(extract, row))) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + list(map(extract, row))) if postfixes is None: postfixes = ['%d' % i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #5
Source File: mlab.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + list(map(extract, row))) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + list(map(extract, row))) if postfixes is None: postfixes = ['%d' % i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #6
Source File: mlab.py From ImageFusion with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + list(map(extract, row))) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + list(map(extract, row))) if postfixes is None: postfixes = ['%d'%i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #7
Source File: mlab.py From coffeegrindsize with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + list(map(extract, row))) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + list(map(extract, row))) if postfixes is None: postfixes = ['%d' % i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)
Example #8
Source File: mlab.py From twitter-stock-recommendation with MIT License | 4 votes |
def recs_join(key, name, recs, jointype='outer', missing=0., postfixes=None): """ Join a sequence of record arrays on single column key. This function only joins a single column of the multiple record arrays *key* is the column name that acts as a key *name* is the name of the column that we want to join *recs* is a list of record arrays to join *jointype* is a string 'inner' or 'outer' *missing* is what any missing field is replaced by *postfixes* if not None, a len recs sequence of postfixes returns a record array with columns [rowkey, name0, name1, ... namen-1]. or if postfixes [PF0, PF1, ..., PFN-1] are supplied, [rowkey, namePF0, namePF1, ... namePFN-1]. Example:: r = recs_join("date", "close", recs=[r0, r1], missing=0.) """ results = [] aligned_iters = cbook.align_iterators(operator.attrgetter(key), *[iter(r) for r in recs]) def extract(r): if r is None: return missing else: return r[name] if jointype == "outer": for rowkey, row in aligned_iters: results.append([rowkey] + list(map(extract, row))) elif jointype == "inner": for rowkey, row in aligned_iters: if None not in row: # throw out any Nones results.append([rowkey] + list(map(extract, row))) if postfixes is None: postfixes = ['%d' % i for i in range(len(recs))] names = ",".join([key] + ["%s%s" % (name, postfix) for postfix in postfixes]) return np.rec.fromrecords(results, names=names)