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


Python lib.generate_slices方法代码示例

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


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

示例1: __iter__

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import generate_slices [as 别名]
def __iter__(self):
        sdata = self._get_sorted_data()

        if self.ngroups == 0:
            # we are inside a generator, rather than raise StopIteration
            # we merely return signal the end
            return

        starts, ends = lib.generate_slices(self.slabels, self.ngroups)

        for i, (start, end) in enumerate(zip(starts, ends)):
            # Since I'm now compressing the group ids, it's now not "possible"
            # to produce empty slices because such groups would not be observed
            # in the data
            # if start >= end:
            #     raise AssertionError('Start %s must be less than end %s'
            #                          % (str(start), str(end)))
            yield i, self._chop(sdata, slice(start, end)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:ops.py

示例2: fast_apply

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import generate_slices [as 别名]
def fast_apply(self, f, names):
        # must return keys::list, values::list, mutated::bool
        try:
            starts, ends = lib.generate_slices(self.slabels, self.ngroups)
        except Exception:
            # fails when all -1
            return [], True

        sdata = self._get_sorted_data()
        results, mutated = reduction.apply_frame_axis0(sdata, f, names,
                                                       starts, ends)

        return results, mutated 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:ops.py

示例3: fast_apply

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import generate_slices [as 别名]
def fast_apply(self, f, names):
        # must return keys::list, values::list, mutated::bool
        try:
            starts, ends = lib.generate_slices(self.slabels, self.ngroups)
        except:
            # fails when all -1
            return [], True

        sdata = self._get_sorted_data()
        results, mutated = lib.apply_frame_axis0(sdata, f, names, starts, ends)

        return results, mutated 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:14,代码来源:groupby.py

示例4: _fast_split_df

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import generate_slices [as 别名]
def _fast_split_df(g_df):
    """
    Note
    ----

    splitting does not scale well to many groups (e.g. 50000+). This is due
    to pandas' (1) use of indexes, (2) some hard coded actions when subsetting.
    We are currently working on a fix, so that when people aren't using indexes,
    nesting will be much faster.

    see https://github.com/machow/siuba/issues/184
    """

    # TODO (#184): speed up when user doesn't need an index
    # right now, this is essentially a copy of
    # pandas.core.groupby.ops.DataSplitter.__iter__
    from pandas._libs import lib
    splitter = g_df.grouper._get_splitter(g_df.obj)

    starts, ends = lib.generate_slices(splitter.slabels, splitter.ngroups)

    # TODO: reset index
    sdata = splitter._get_sorted_data()

    # TODO: avoid costly make_block call, and hard-coded BlockManager init actions.
    #       neither of these things is necessary when subsetting rows.
    for start, end in zip(starts, ends):
        yield splitter._chop(sdata, slice(start, end)) 
开发者ID:machow,项目名称:siuba,代码行数:30,代码来源:verbs.py


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