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


Python DataFrame.shift方法代码示例

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


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

示例1: shift

# 需要导入模块: from pandas.core.frame import DataFrame [as 别名]
# 或者: from pandas.core.frame.DataFrame import shift [as 别名]
def shift(self, periods=1, freq=None, axis='major'):
        """
        Shift index by desired number of periods with an optional time freq.

        The shifted data will not include the dropped periods and the
        shifted axis will be smaller than the original. This is different
        from the behavior of DataFrame.shift()

        Parameters
        ----------
        periods : int
            Number of periods to move, can be positive or negative
        freq : DateOffset, timedelta, or time rule string, optional
        axis : {'items', 'major', 'minor'} or {0, 1, 2}

        Returns
        -------
        shifted : Panel
        """
        if freq:
            return self.tshift(periods, freq, axis=axis)

        return super(Panel, self).slice_shift(periods, axis=axis) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:panel.py

示例2: shift

# 需要导入模块: from pandas.core.frame import DataFrame [as 别名]
# 或者: from pandas.core.frame.DataFrame import shift [as 别名]
def shift(self, periods=1, freq=None, axis='major'):
        """
        Shift index by desired number of periods with an optional time freq.
        The shifted data will not include the dropped periods and the
        shifted axis will be smaller than the original. This is different
        from the behavior of DataFrame.shift()

        Parameters
        ----------
        periods : int
            Number of periods to move, can be positive or negative
        freq : DateOffset, timedelta, or time rule string, optional
        axis : {'items', 'major', 'minor'} or {0, 1, 2}

        Returns
        -------
        shifted : Panel
        """
        if freq:
            return self.tshift(periods, freq, axis=axis)

        return super(Panel, self).slice_shift(periods, axis=axis) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:24,代码来源:panel.py

示例3: shift

# 需要导入模块: from pandas.core.frame import DataFrame [as 别名]
# 或者: from pandas.core.frame.DataFrame import shift [as 别名]
def shift(self, lags, freq=None, axis='major'):
        """
        Shift major or minor axis by specified number of leads/lags. Drops
        periods right now compared with DataFrame.shift

        Parameters
        ----------
        lags : int
        axis : {'major', 'minor'}

        Returns
        -------
        shifted : Panel
        """
        values = self.values
        items = self.items
        major_axis = self.major_axis
        minor_axis = self.minor_axis

        if freq:
            return self.tshift(lags, freq, axis=axis)

        if lags > 0:
            vslicer = slice(None, -lags)
            islicer = slice(lags, None)
        elif lags == 0:
            vslicer = islicer = slice(None)
        else:
            vslicer = slice(-lags, None)
            islicer = slice(None, lags)

        axis = self._get_axis_name(axis)
        if axis == 'major_axis':
            values = values[:, vslicer, :]
            major_axis = major_axis[islicer]
        elif axis == 'minor_axis':
            values = values[:, :, vslicer]
            minor_axis = minor_axis[islicer]
        else:
            raise ValueError('Invalid axis')

        return self._constructor(values, items=items, major_axis=major_axis,
                                 minor_axis=minor_axis) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:45,代码来源:panel.py


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