pandas numpy

作者: cajan2 | 来源:发表于2017-03-08 16:20 被阅读57次

    pandas 时间序列操作

    python numpy教程

    Numpy中矩阵对象(matrix)

    numpy中的数据类型转换,不能直接改原数据的dtype! 只能用函数astype()

     b = np.array([1., 2., 3., 4.])
      c = b.astype(int)
    
    

    重采样resample

    Question:

    我有一个pandas.Series数据-事件的基本序列:
    0  2012-09-05 19:28:52
    1  2012-09-05 19:28:52
    2  2012-09-05 19:44:37
    3  2012-09-05 19:44:37
    4  2012-09-05 20:04:53
    5  2012-09-05 20:04:53
    6  2012-09-05 20:12:59
    7  2012-09-05 20:13:15
    8  2012-09-05 20:13:15
    9  2012-09-05 20:13:15
    
    我想创建一个pandas.TimeSeries在一个特定的pandas.date_range(例如15分钟的时间间隔;pandas.date_range(start, end, freq='15T'))持有的每个周期的事件的计数。这是怎么回事 谢谢
    

    Answer:

    timestamp                     event_id
    2012-09-05 19:28:52   0
    2012-09-05 19:28:52   1
    2012-09-05 19:44:37   2
    2012-09-05 19:44:37   3
    2012-09-05 20:04:53   4
    2012-09-05 20:04:53   5
    2012-09-05 20:12:59   6
    2012-09-05 20:13:15   7
    2012-09-05 20:13:15   8
    2012-09-05 20:13:15   9
    In [48]: s.resample('15Min', how=len)
    Out[48]:
    timestamp                   event_id
    2012-09-05 19:30:00   2
    2012-09-05 19:45:00   2
    2012-09-05 20:00:00   0
    2012-09-05 20:15:00   6
    

    Python科学计算 第二版

    【量化小讲堂 - Python、Pandas系列】数据告诉你:惊人的海龟交易法则

    相关文章

      网友评论

        本文标题:pandas numpy

        本文链接:https://www.haomeiwen.com/subject/powbgttx.html