period.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码
def __array_wrap__(self, result, context=None):
        """
        Gets called after a ufunc. Needs additional handling as
        PeriodIndex stores internal data as int dtype

        Replace this to __numpy_ufunc__ in future version
        """
        if isinstance(context, tuple) and len(context) > 0:
            func = context[0]
            if (func is np.add):
                return self._add_delta(context[1][1])
            elif (func is np.subtract):
                return self._add_delta(-context[1][1])
            elif isinstance(func, np.ufunc):
                if 'M->M' not in func.types:
                    msg = "ufunc '{0}' not supported for the PeriodIndex"
                    # This should be TypeError, but TypeError cannot be raised
                    # from here because numpy catches.
                    raise ValueError(msg.format(func.__name__))

        if com.is_bool_dtype(result):
            return result
        return PeriodIndex(result, freq=self.freq, name=self.name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号