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


Python frequencies.is_superperiod方法代码示例

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


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

示例1: _adjust_bin_edges

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _adjust_bin_edges(self, binner, ax_values):
        # Some hacks for > daily data, see #1471, #1458, #1483

        bin_edges = binner.asi8

        if self.freq != 'D' and is_superperiod(self.freq, 'D'):
            day_nanos = delta_to_nanoseconds(timedelta(1))
            if self.closed == 'right':
                bin_edges = bin_edges + day_nanos - 1

            # intraday values on last day
            if bin_edges[-2] > ax_values.max():
                bin_edges = bin_edges[:-1]
                binner = binner[:-1]

        return binner, bin_edges 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:resample.py

示例2: _maybe_resample

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _maybe_resample(series, ax, freq, plotf, kwargs):
    ax_freq = _get_ax_freq(ax)
    if ax_freq is not None and freq != ax_freq:
        if frequencies.is_superperiod(freq, ax_freq):  # upsample input
            series = series.copy()
            series.index = series.index.asfreq(ax_freq, how='s')
            freq = ax_freq
        elif _is_sup(freq, ax_freq):  # one is weekly
            how = kwargs.pop('how', 'last')
            series = series.resample('D', how=how).dropna()
            series = series.resample(ax_freq, how=how).dropna()
            freq = ax_freq
        elif frequencies.is_subperiod(freq, ax_freq) or _is_sub(freq, ax_freq):
            _upsample_others(ax, freq, plotf, kwargs)
            ax_freq = freq
        else:  # pragma: no cover
            raise ValueError('Incompatible frequency conversion')
    return freq, ax_freq, series 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:plotting.py

示例3: _adjust_bin_edges

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _adjust_bin_edges(self, binner, ax_values):
        # Some hacks for > daily data, see #1471, #1458, #1483

        bin_edges = binner.asi8

        if self.freq != 'D' and is_superperiod(self.freq, 'D'):
            day_nanos = _delta_to_nanoseconds(timedelta(1))
            if self.closed == 'right':
                bin_edges = bin_edges + day_nanos - 1

            # intraday values on last day
            if bin_edges[-2] > ax_values[-1]:
                bin_edges = bin_edges[:-1]
                binner = binner[:-1]

        return binner, bin_edges 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:resample.py

示例4: _adjust_bin_edges

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _adjust_bin_edges(self, binner, ax_values):
        # Some hacks for > daily data, see #1471, #1458, #1483

        bin_edges = binner.asi8

        if self.freq != 'D' and is_superperiod(self.freq, 'D'):
            day_nanos = _delta_to_nanoseconds(timedelta(1))
            if self.closed == 'right':
                bin_edges = bin_edges + day_nanos - 1

            # intraday values on last day
            if bin_edges[-2] > ax_values.max():
                bin_edges = bin_edges[:-1]
                binner = binner[:-1]

        return binner, bin_edges 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:18,代码来源:resample.py

示例5: test_is_superperiod_subperiod

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def test_is_superperiod_subperiod():

    # input validation
    assert not (frequencies.is_superperiod(offsets.YearEnd(), None))
    assert not (frequencies.is_subperiod(offsets.MonthEnd(), None))
    assert not (frequencies.is_superperiod(None, offsets.YearEnd()))
    assert not (frequencies.is_subperiod(None, offsets.MonthEnd()))
    assert not (frequencies.is_superperiod(None, None))
    assert not (frequencies.is_subperiod(None, None))

    assert (frequencies.is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (frequencies.is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (frequencies.is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (frequencies.is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (frequencies.is_superperiod(offsets.Second(), offsets.Milli()))
    assert (frequencies.is_subperiod(offsets.Milli(), offsets.Second()))

    assert (frequencies.is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (frequencies.is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (frequencies.is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (frequencies.is_subperiod(offsets.Nano(), offsets.Micro())) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:26,代码来源:test_frequencies.py

示例6: _maybe_resample

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _maybe_resample(series, ax, kwargs):
    # resample against axes freq if necessary
    freq, ax_freq = _get_freq(ax, series)

    if freq is None:  # pragma: no cover
        raise ValueError('Cannot use dynamic axis without frequency info')

    # Convert DatetimeIndex to PeriodIndex
    if isinstance(series.index, DatetimeIndex):
        series = series.to_period(freq=freq)

    if ax_freq is not None and freq != ax_freq:
        if frequencies.is_superperiod(freq, ax_freq):  # upsample input
            series = series.copy()
            series.index = series.index.asfreq(ax_freq, how='s')
            freq = ax_freq
        elif _is_sup(freq, ax_freq):  # one is weekly
            how = kwargs.pop('how', 'last')
            series = getattr(series.resample('D'), how)().dropna()
            series = getattr(series.resample(ax_freq), how)().dropna()
            freq = ax_freq
        elif frequencies.is_subperiod(freq, ax_freq) or _is_sub(freq, ax_freq):
            _upsample_others(ax, freq, kwargs)
            ax_freq = freq
        else:  # pragma: no cover
            raise ValueError('Incompatible frequency conversion')
    return freq, series 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:29,代码来源:_timeseries.py

示例7: _is_sup

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _is_sup(f1, f2):
    return ((f1.startswith('W') and frequencies.is_superperiod('D', f2)) or
            (f2.startswith('W') and frequencies.is_superperiod(f1, 'D'))) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:_timeseries.py

示例8: _downsample

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _downsample(self, how, **kwargs):
        """
        Downsample the cython defined function

        Parameters
        ----------
        how : string / cython mapped function
        **kwargs : kw args passed to how function
        """

        # we may need to actually resample as if we are timestamps
        if self.kind == 'timestamp':
            return super(PeriodIndexResampler, self)._downsample(how, **kwargs)

        how = self._is_cython_func(how) or how
        ax = self.ax

        if is_subperiod(ax.freq, self.freq):
            # Downsampling
            return self._groupby_and_aggregate(how, grouper=self.grouper)
        elif is_superperiod(ax.freq, self.freq):
            if how == 'ohlc':
                # GH #13083
                # upsampling to subperiods is handled as an asfreq, which works
                # for pure aggregating/reducing methods
                # OHLC reduces along the time dimension, but creates multiple
                # values for each period -> handle by _groupby_and_aggregate()
                return self._groupby_and_aggregate(how, grouper=self.grouper)
            return self.asfreq()
        elif ax.freq == self.freq:
            return self.asfreq()

        raise IncompatibleFrequency(
            'Frequency {} cannot be resampled to {}, as they are not '
            'sub or super periods'.format(ax.freq, self.freq)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:37,代码来源:resample.py

示例9: test_is_superperiod_subperiod

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def test_is_superperiod_subperiod():
    assert(fmod.is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert(fmod.is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert(fmod.is_superperiod(offsets.Hour(), offsets.Minute()))
    assert(fmod.is_subperiod(offsets.Minute(), offsets.Hour())) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_frequencies.py

示例10: _resample_periods

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import is_superperiod [as 别名]
def _resample_periods(self, obj):
        axlabels = obj._get_axis(self.axis)

        if len(axlabels) == 0:
            new_index = PeriodIndex(data=[], freq=self.freq)
            return obj.reindex(new_index)
        else:
            start = axlabels[0].asfreq(self.freq, how=self.convention)
            end = axlabels[-1].asfreq(self.freq, how='end')

            new_index = period_range(start, end, freq=self.freq)

        # Start vs. end of period
        memb = axlabels.asfreq(self.freq, how=self.convention)

        if is_subperiod(axlabels.freq, self.freq) or self.how is not None:
            # Downsampling
            rng = np.arange(memb.values[0], memb.values[-1] + 1)
            bins = memb.searchsorted(rng, side='right')
            grouper = BinGrouper(bins, new_index)

            grouped = obj.groupby(grouper, axis=self.axis)
            return grouped.aggregate(self._agg_method)
        elif is_superperiod(axlabels.freq, self.freq):
            # Get the fill indexer
            indexer = memb.get_indexer(new_index, method=self.fill_method,
                                       limit=self.limit)

            return _take_new_index(obj, indexer, new_index, axis=self.axis)
        else:
            raise ValueError('Frequency %s cannot be resampled to %s'
                             % (axlabels.freq, self.freq)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:34,代码来源:resample.py


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