【问题标题】:How to find the periodicity (if it exists) of a Pandas Time Series?如何找到 Pandas 时间序列的周期性(如果存在)?
【发布时间】:2019-03-27 12:46:38
【问题描述】:

我的问题是:

假设我有一个 Pandas 时间序列,所以日期作为索引和一个数字列。 我想知道找到它的周期性或近似值的最简单方法是什么。

谁能向我解释解决这个问题的不同步骤是什么?

提前感谢您的帮助,

亚历克斯:)

【问题讨论】:

    标签: pandas time-series periodicity


    【解决方案1】:

    其实很简单,不需要太多步骤,因为 pandas 已经用 pd.infer_freq() 为你做了这些。

    只是你的一个小例子,我们可以有这样的东西:

    import pandas as pd
    import numpy as np
    
    df = pd.DataFrame({'date': pd.date_range(start='2020-01-01', end='2021-12-31', freq='D'),
                       'number': np.random.uniform(size=731)})
    
    df.set_index(df.date, inplace=True)
    
    pd.infer_freq(df.index)
    

    【讨论】:

      猜你喜欢
      • 2019-05-02
      • 2023-03-04
      • 2017-02-28
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 2017-07-19
      相关资源
      最近更新 更多