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


Python TimeSeries.sort_timeseries方法代码示例

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


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

示例1: execute

# 需要导入模块: from pycast.common.timeseries import TimeSeries [as 别名]
# 或者: from pycast.common.timeseries.TimeSeries import sort_timeseries [as 别名]
    def execute(self, timeSeries):
        """Creates a new TimeSeries containing the SMA values for the predefined windowsize.

        :param TimeSeries timeSeries:    The TimeSeries used to calculate the simple moving average values.

        :return:    TimeSeries object containing the smooth moving average.
        :rtype:     TimeSeries

        :raise:   Raises a :py:exc:`ValueError` wif the defined windowsize is larger than the number of elements
            in timeSeries

        :note:    This implementation aims to support independent for loop execution.
        """
        windowsize    = self._parameters["windowsize"]

        if len (timeSeries) < windowsize:
            raise ValueError("windowsize is larger than the number of elements in timeSeries.")

        tsLength      = len(timeSeries)
        nbrOfLoopRuns = tsLength - windowsize + 1

        res = TimeSeries()
        for idx in xrange(nbrOfLoopRuns):
            end = idx + windowsize
            data = timeSeries[idx:end]

            timestamp = data[windowsize//2][0]
            value     = sum([i[1] for i in data])/windowsize

            res.add_entry(timestamp, value)

        res.sort_timeseries()
        return res
开发者ID:T-002,项目名称:pycast,代码行数:35,代码来源:simplemovingaverage.py

示例2: timeseries_sort_test

# 需要导入模块: from pycast.common.timeseries import TimeSeries [as 别名]
# 或者: from pycast.common.timeseries.TimeSeries import sort_timeseries [as 别名]
    def timeseries_sort_test(self):
        """Tests the sort_timeseries function."""
        data = [[0.0, 0.0], [0.1, 0.1], [0.2, 0.2], [0.3, 0.3], [0.4, 0.4], [0.5, 0.5]]
        ts   = TimeSeries.from_twodim_list(data)
        
        ts.sort_timeseries()
        ts.sort_timeseries(False)

        ts = TimeSeries(isSorted=True)
        ts.sort_timeseries()
开发者ID:fleupold,项目名称:pycast,代码行数:12,代码来源:timeseriesmiscellaneoustest.py


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