import pandas
x = pandas.read_csv('data.csv', parse_dates=True, index_col='DateTime',
names=['DateTime', 'X'], header=None, sep=';')
使用此data.csv文件:
1449054136.83;15.31
1449054137.43;16.19
1449054138.04;19.22
1449054138.65;15.12
1449054139.25;13.12
(第1列是UNIX时间戳,即自1970年1月1日以来经过的秒数),每隔15秒用x.resample(’15S’)重新采样数据时出现此错误:
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex
这就像尚未解析的“日期时间”信息:
X
DateTime
1.449054e+09 15.31
1.449054e+09 16.19
...
如何使用pandas模块导入日期存储为时间戳的.CSV?
然后,一旦我能够导入CSV,如何访问日期>的行. 2015-12-02 12:02:18?
本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/shiyongpandasduqudaiyoushijianchuoliedecsv.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 27, 2019 at 01:26 下午