pandas 时间序列分析(一)—— 基础

    xiaoxiao2021-04-15  42

    0. 以时间作为序列的索引

    >> from datetime import datetime >> dates = [datetime(2011, 1, i) for i in [2, 5, 7, 8, 10, 12]] >> ts = pd.Series(np.random.randn(6), index=dates) >> ts 2011-01-02 -1.157516 2011-01-05 0.755876 2011-01-07 0.299113 2011-01-08 0.446367 2011-01-10 -1.700069 2011-01-12 0.261344 dtype: float64

    进一步查看 ts 的成员:

    >> type(ts) pandas.core.series.Series >> ts.index ... >> ts.index.dtype dtype('<M8[ns]') # 这是对于小端机的结果; >> ts.index[0] Timestamp('2011-01-02 00:00:00')
    转载请注明原文地址: https://ju.6miu.com/read-671155.html

    最新回复(0)