【问题标题】:Library for time-series data时间序列数据库
【发布时间】:2015-01-19 03:29:31
【问题描述】:

我正在寻找一个使用 perl、python 甚至 LISP 的开源库来处理时间序列数据。数据将从 CSV 文件中读取:数据运行长度通常为每 10 分钟一次,持续两年。任何人都可以推荐一个库,它允许我将数据加载到一个对象中,例如,从数据集中“排除 13:00 到 19:00 之间的所有星期日”,或者方便地创建一个包含我想要排除的所有时段的对象和对原始数据集进行 AND 操作。每个时间样本必须能够处理一组以上的值。

我看过 pandas for python,看起来很有希望,还有其他想到的吗?

【问题讨论】:

    标签: time-series


    【解决方案1】:

    Pandas 无疑是一种不错的选择。 R 语言对时间序列也有很好的支持。

    from pandas import Series, date_range
    from numpy.random import randn
    rng = date_range('1/1/2011', periods=10000, freq='10min')
    ts = Series(randn(len(rng)), index=rng)
    
    filtered_index = rng[((rng.dayofweek!=6) | ((rng.hour < 13) | (rng.hour>=19)))]
    no_sunday_afternoons = ts[filtered_index]
    print no_sunday_afternoons['2011-01-02 12:30:00':'2011-01-02 19:30:00']
    
    
    2011-01-02 12:30:00   -1.395918
    2011-01-02 12:40:00    0.382604
    2011-01-02 12:50:00   -0.422495
    2011-01-02 19:00:00   -0.341497
    2011-01-02 19:10:00    0.982950
    2011-01-02 19:20:00   -0.909796
    2011-01-02 19:30:00    0.842446
    dtype: float64
    

    【讨论】:

    • 这正是我所追求的。感谢您花时间编写示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 2017-03-07
    相关资源
    最近更新 更多