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


Python concat._concat_compat方法代码示例

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


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

示例1: is_uniform_join_units

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def is_uniform_join_units(join_units):
    """
    Check if the join units consist of blocks of uniform type that can
    be concatenated using Block.concat_same_type instead of the generic
    concatenate_join_units (which uses `_concat._concat_compat`).

    """
    return (
        # all blocks need to have the same type
        all(type(ju.block) is type(join_units[0].block) for ju in join_units) and  # noqa
        # no blocks that would get missing values (can lead to type upcasts)
        # unless we're an extension dtype.
        all(not ju.is_na or ju.block.is_extension for ju in join_units) and
        # no blocks with indexers (as then the dimensions do not fit)
        all(not ju.indexers for ju in join_units) and
        # disregard Panels
        all(ju.block.ndim <= 2 for ju in join_units) and
        # only use this path when there is something to concatenate
        len(join_units) > 1) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:concat.py

示例2: _fast_union

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def _fast_union(self, other):
        if len(other) == 0:
            return self.view(type(self))

        if len(self) == 0:
            return other.view(type(self))

        # to make our life easier, "sort" the two ranges
        if self[0] <= other[0]:
            left, right = self, other
        else:
            left, right = other, self

        left_end = left[-1]
        right_end = right[-1]

        # concatenate
        if left_end < right_end:
            loc = right.searchsorted(left_end, side='right')
            right_chunk = right.values[loc:]
            dates = _concat._concat_compat((left.values, right_chunk))
            return self._shallow_copy(dates)
        else:
            return left 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:timedeltas.py

示例3: is_uniform_join_units

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def is_uniform_join_units(join_units):
    """
    Check if the join units consist of blocks of uniform type that can
    be concatenated using Block.concat_same_type instead of the generic
    concatenate_join_units (which uses `_concat._concat_compat`).

    """
    return (
        # all blocks need to have the same type
        all([type(ju.block) is type(join_units[0].block) for ju in join_units]) and  # noqa
        # no blocks that would get missing values (can lead to type upcasts)
        all([not ju.is_na for ju in join_units]) and
        # no blocks with indexers (as then the dimensions do not fit)
        all([not ju.indexers for ju in join_units]) and
        # disregard Panels
        all([ju.block.ndim <= 2 for ju in join_units]) and
        # only use this path when there is something to concatenate
        len(join_units) > 1) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:20,代码来源:internals.py

示例4: concatenate_join_units

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def concatenate_join_units(join_units, concat_axis, copy):
    """
    Concatenate values from several join units along selected axis.
    """
    if concat_axis == 0 and len(join_units) > 1:
        # Concatenating join units along ax0 is handled in _merge_blocks.
        raise AssertionError("Concatenating join units along axis0")

    empty_dtype, upcasted_na = get_empty_dtype_and_na(join_units)

    to_concat = [ju.get_reindexed_values(empty_dtype=empty_dtype,
                                         upcasted_na=upcasted_na)
                 for ju in join_units]

    if len(to_concat) == 1:
        # Only one block, nothing to concatenate.
        concat_values = to_concat[0]
        if copy and concat_values.base is not None:
            concat_values = concat_values.copy()
    else:
        concat_values = _concat._concat_compat(to_concat, axis=concat_axis)

    return concat_values 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:25,代码来源:internals.py

示例5: concatenate_join_units

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def concatenate_join_units(join_units, concat_axis, copy):
    """
    Concatenate values from several join units along selected axis.
    """
    if concat_axis == 0 and len(join_units) > 1:
        # Concatenating join units along ax0 is handled in _merge_blocks.
        raise AssertionError("Concatenating join units along axis0")

    empty_dtype, upcasted_na = get_empty_dtype_and_na(join_units)

    to_concat = [ju.get_reindexed_values(empty_dtype=empty_dtype,
                                         upcasted_na=upcasted_na)
                 for ju in join_units]

    if len(to_concat) == 1:
        # Only one block, nothing to concatenate.
        concat_values = to_concat[0]
        if copy:
            if isinstance(concat_values, np.ndarray):
                # non-reindexed (=not yet copied) arrays are made into a view
                # in JoinUnit.get_reindexed_values
                if concat_values.base is not None:
                    concat_values = concat_values.copy()
            else:
                concat_values = concat_values.copy()
    else:
        concat_values = _concat._concat_compat(to_concat, axis=concat_axis)

    return concat_values 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:31,代码来源:concat.py

示例6: concat

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def concat(self, to_concat, new_axis):
        """
        Concatenate a list of SingleBlockManagers into a single
        SingleBlockManager.

        Used for pd.concat of Series objects with axis=0.

        Parameters
        ----------
        to_concat : list of SingleBlockManagers
        new_axis : Index of the result

        Returns
        -------
        SingleBlockManager

        """
        non_empties = [x for x in to_concat if len(x) > 0]

        # check if all series are of the same block type:
        if len(non_empties) > 0:
            blocks = [obj.blocks[0] for obj in non_empties]
            if len({b.dtype for b in blocks}) == 1:
                new_block = blocks[0].concat_same_type(blocks)
            else:
                values = [x.values for x in blocks]
                values = _concat._concat_compat(values)
                new_block = make_block(
                    values, placement=slice(0, len(values), 1))
        else:
            values = [x._block.values for x in to_concat]
            values = _concat._concat_compat(values)
            new_block = make_block(
                values, placement=slice(0, len(values), 1))

        mgr = SingleBlockManager(new_block, new_axis)
        return mgr


# --------------------------------------------------------------------
# Constructor Helpers 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:43,代码来源:managers.py

示例7: _fast_union

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def _fast_union(self, other):
        if len(other) == 0:
            return self.view(type(self))

        if len(self) == 0:
            return other.view(type(self))

        # to make our life easier, "sort" the two ranges
        if self[0] <= other[0]:
            left, right = self, other
        else:
            left, right = other, self

        left_end = left[-1]
        right_end = right[-1]

        # TODO: consider re-implementing freq._should_cache for fastpath

        # concatenate dates
        if left_end < right_end:
            loc = right.searchsorted(left_end, side='right')
            right_chunk = right.values[loc:]
            dates = _concat._concat_compat((left.values, right_chunk))
            return self._shallow_copy(dates)
        else:
            return left 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:28,代码来源:datetimes.py

示例8: _fast_union

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def _fast_union(self, other):
        if len(other) == 0:
            return self.view(type(self))

        if len(self) == 0:
            return other.view(type(self))

        # to make our life easier, "sort" the two ranges
        if self[0] <= other[0]:
            left, right = self, other
        else:
            left, right = other, self

        left_start, left_end = left[0], left[-1]
        right_end = right[-1]

        if not self.freq._should_cache():
            # concatenate dates
            if left_end < right_end:
                loc = right.searchsorted(left_end, side='right')
                right_chunk = right.values[loc:]
                dates = _concat._concat_compat((left.values, right_chunk))
                return self._shallow_copy(dates)
            else:
                return left
        else:
            return type(self)(start=left_start,
                              end=max(left_end, right_end),
                              freq=left.freq) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:31,代码来源:datetimes.py

示例9: concat

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def concat(self, to_concat, new_axis):
        """
        Concatenate a list of SingleBlockManagers into a single
        SingleBlockManager.

        Used for pd.concat of Series objects with axis=0.

        Parameters
        ----------
        to_concat : list of SingleBlockManagers
        new_axis : Index of the result

        Returns
        -------
        SingleBlockManager

        """
        non_empties = [x for x in to_concat if len(x) > 0]

        # check if all series are of the same block type:
        if len(non_empties) > 0:
            blocks = [obj.blocks[0] for obj in non_empties]

            if all(type(b) is type(blocks[0]) for b in blocks[1:]):  # noqa
                new_block = blocks[0].concat_same_type(blocks)
            else:
                values = [x.values for x in blocks]
                values = _concat._concat_compat(values)
                new_block = make_block(
                    values, placement=slice(0, len(values), 1))
        else:
            values = [x._block.values for x in to_concat]
            values = _concat._concat_compat(values)
            new_block = make_block(
                values, placement=slice(0, len(values), 1))

        mgr = SingleBlockManager(new_block, new_axis)
        return mgr 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:40,代码来源:internals.py

示例10: _fast_union

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def _fast_union(self, other):
        if len(other) == 0:
            return self.view(type(self))

        if len(self) == 0:
            return other.view(type(self))

        # to make our life easier, "sort" the two ranges
        if self[0] <= other[0]:
            left, right = self, other
        else:
            left, right = other, self

        left_start, left_end = left[0], left[-1]
        right_end = right[-1]

        if not self.offset._should_cache():
            # concatenate dates
            if left_end < right_end:
                loc = right.searchsorted(left_end, side='right')
                right_chunk = right.values[loc:]
                dates = _concat._concat_compat((left.values, right_chunk))
                return self._shallow_copy(dates)
            else:
                return left
        else:
            return type(self)(start=left_start,
                              end=max(left_end, right_end),
                              freq=left.offset) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:31,代码来源:datetimes.py

示例11: concat

# 需要导入模块: from pandas.core.dtypes import concat [as 别名]
# 或者: from pandas.core.dtypes.concat import _concat_compat [as 别名]
def concat(self, to_concat, new_axis):
        """
        Concatenate a list of SingleBlockManagers into a single
        SingleBlockManager.

        Used for pd.concat of Series objects with axis=0.

        Parameters
        ----------
        to_concat : list of SingleBlockManagers
        new_axis : Index of the result

        Returns
        -------
        SingleBlockManager

        """
        non_empties = [x for x in to_concat if len(x) > 0]

        # check if all series are of the same block type:
        if len(non_empties) > 0:
            blocks = [obj.blocks[0] for obj in non_empties]

            if all([type(b) is type(blocks[0]) for b in blocks[1:]]):  # noqa
                new_block = blocks[0].concat_same_type(blocks)
            else:
                values = [x.values for x in blocks]
                values = _concat._concat_compat(values)
                new_block = make_block(
                    values, placement=slice(0, len(values), 1))
        else:
            values = [x._block.values for x in to_concat]
            values = _concat._concat_compat(values)
            new_block = make_block(
                values, placement=slice(0, len(values), 1))

        mgr = SingleBlockManager(new_block, new_axis)
        return mgr 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:40,代码来源:internals.py


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