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


Python cbook.align_iterators方法代码示例

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


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

示例1: recs_join

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import align_iterators [as 别名]
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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:55,代码来源:mlab.py

示例2: recs_join

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import align_iterators [as 别名]
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) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:55,代码来源:mlab.py

示例3: recs_join

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import align_iterators [as 别名]
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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:58,代码来源:mlab.py


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