noaa.py 文件源码

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

项目:eemeter 作者: openeemeter 项目源码 文件源码
def indexed_temperatures(self, index, unit, allow_mixed_frequency=False):
        ''' Return average temperatures over the given index.

        Parameters
        ----------
        index : pandas.DatetimeIndex
            Index over which to supply average temperatures.
            The :code:`index` should be given as either an hourly ('H') or
            daily ('D') frequency.
        unit : str, {"degF", "degC"}
            Target temperature unit for returned temperature series.

        Returns
        -------
        temperatures : pandas.Series with DatetimeIndex
            Average temperatures over series indexed by :code:`index`.
        '''

        if index.shape == (0,):
            return pd.Series([], index=index, dtype=float)

        self._verify_index_presence(index)  # fetches weather data if needed

        if index.freq is not None:
            freq = index.freq
        else:
            try:
                freq = pd.infer_freq(index)
            except ValueError:
                freq = None

        if freq == 'D':
            return self._daily_indexed_temperatures(index, unit)
        elif freq == 'H':
            return self._hourly_indexed_temperatures(index, unit)
        elif allow_mixed_frequency:
            return self._mixed_frequency_indexed_temperatures(index, unit)
        else:
            message = 'DatetimeIndex with unknown frequency not supported.'
            raise ValueError(message)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号