【发布时间】:2022-01-19 03:02:33
【问题描述】:
我正在尝试从 csv 制作日期时间列表,以将我的结果与检测到的 LSTM 测试相匹配。
每当我使用循环提取日期时间和值时,我总是会得到带有日期时间的非字符串单词“时间戳”。
我的代码在这里:
m = [ 49, 50] #index of results which I have to match with datetime to extract all information
result_details = []
for index, rows in df.iterrows():
if index in m:
result_details.append([rows[0],
rows[1]])
print(result_details)
我的 csv:
datetimeAt value
0 2021-12-01 00:00:00 0.000
5 2021-12-01 01:00:00 0.000
10 2021-12-01 02:00:00 0.000
15 2021-12-01 03:00:00 0.000
20 2021-12-01 04:00:00 0.000
... ... ...
1149 2021-12-10 13:00:00 2.756
1154 2021-12-10 14:00:00 1.297
1159 2021-12-10 15:00:00 1.503
1164 2021-12-10 16:00:00 1.417
1169 2021-12-10 17:00:00 0.084
每当我追加时,我都会像这样:
[[Timestamp('2021-12-01 10:00:00'), 13.266044921875],
[Timestamp('2021-12-01 09:00:00'), 9.5365595703125]]
如何获得如下输出? (只有日期和值,没有元组、字符串和单词)
[2021-12-01 10:00:00, 13.266044921875],
[2021-12-01 09:00:00, 9.5365595703125]]
【问题讨论】:
标签: python python-3.x list csv datetime