Concat Pandas时间序列给出AttributeError:“TimeSeries”对象没有属性“\

2024-10-02 14:30:41 发布

您现在位置:Python中文网/ 问答频道 /正文

当合并两个pandas时间序列对象resample'edprices和{}在一起时,Python抛出一个错误。在

为什么2个时间序列不能连接在一起?在

编码

prices = [float(t.price) for t in tradeHistory]
amounts = [float(t.amount) for t in tradeHistory]
df = pd.DataFrame({'price':prices, 'amount':amounts}, index=[t.date for t in tradeHistory])

ohlcPrice = df['price'].resample('min', how='ohlc')
ohlcVolume = df['amount'].resample('min', how='sum')

pd.concat([ohlcPrice, ohlcVolume], axis=1)

错误:AttributeError: 'TimeSeries' object has no attribute '_data'


价格

[9.74401, 9.74401, 9.744, 9.744, 9.744, 9.744, 9.744, 9.74401, 9.74401, 9.74401, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78998, 9.78819, 9.78819, 9.78819, 9.744, 9.694, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.699, 9.72, 9.724, 9.72898, 9.72899, 9.729, 9.729, 9.73374, 9.73897, 9.73899, 9.739, 9.739, 9.739, 9.739, 9.73998, 9.74, 9.74, 9.74, 9.741, 9.78998, 9.741, 9.744, 9.744, 9.744, 9.744, 9.744, 9.753, 9.7499, 9.79, 9.76, 9.753, 9.74, 9.74, 9.741, 9.7469, 9.7499, 9.7499, 9.7499, 9.7469, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.7499, 9.74996, 9.7501, 9.74999, 9.75, 9.75, 9.75, 9.75, 9.75, 9.75001, 9.75003, 9.75003, 9.751, 9.751, 9.751, 9.751, 9.75101, 9.79997, 9.751, 9.751, 9.79997, 9.75, 9.75, 9.75, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.753, 9.75, 9.79, 9.79, 9.79, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8, 9.8079, 9.8, 9.8, 9.8, 9.8079, 9.8, 9.8, 9.8, 9.8, 9.8]

金额

[5.70192, 1.5391, 29.9542, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 6.78, 66.0296, 50.0, 0.5, 1.0, 0.4087, 1.0, 92.3407, 5.0, 0.236463, 0.7, 1.0, 1.0, 0.1, 1.0, 1.0, 0.3, 5.0, 8.25753, 2.06207, 2.06207, 16.0321, 16.0321, 300.0, 5.0, 8.15837, 22.7703, 2.06207, 0.102286, 2.06207, 0.2, 0.2, 0.3, 0.2, 0.2, 0.2, 0.2, 0.2, 0.33968, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 5.0, 1464.29, 207.429, 49.3676, 1996.65, 0.3, 3.35086, 4.88604, 3.1843, 7.75833, 80.9128, 0.144532, 15.0, 0.395092, 0.756672, 1.996, 4.9943, 4.63244, 0.105, 0.2, 0.0625584, 79.7389, 7.75374, 4.5, 0.137442, 7.75374, 10.3198, 7.75374, 0.38, 0.11, 10.2994, 7.75374, 2.83, 7.75374, 13.1484, 2.77207, 0.445, 5.0, 6.33777, 5.0, 1.0, 1.0, 0.92, 1.0, 1.0, 1.0, 7.75364, 4.30294, 1.0, 1.0, 1.0, 1.0, 1.0, 0.3, 0.357, 1.0, 1.0, 0.08, 1.0, 1.0, 408.133, 84.8729, 1.0, 1.0, 1.0, 1.0, 2.994, 0.859352, 9.14065, 990.859, 5.0, 25.2, 166.283, 20.0, 0.945431, 0.421266, 0.24432, 0.78568, 3.56884, 5.33, 8.25341, 2.0, 10.0, 154.096, 38.0652, 6.704, 3.296, 100.0, 22.455, 259.2, 99.8, 28.14, 1.5, 47.8398, 131.547]


Tags: indffor错误时间序列floatamount