我想知道如何从这些数据制作Matlab时间表:
date time open high low close tickvol
0 2011.01.02 17:01 1.3342 1.3344 1.3341 1.3341 0
1 2011.01.02 17:02 1.3343 1.3343 1.3343 1.3343 0
2 2011.01.02 17:03 1.3344 1.3344 1.3344 1.3344 0
3 2011.01.02 17:06 1.3345 1.3349 1.3345 1.3348 0
4 2011.01.02 17:07 1.3346 1.3346 1.3346 1.3346 0
... ... ... ... ... ... ... ...
4558998 2023.05.19 16:54 1.08051 1.08057 1.08046 1.08046 0
4558999 2023.05.19 16:55 1.08047 1.08055 1.08042 1.08054 0
4559000 2023.05.19 16:56 1.08053 1.08058 1.0805 1.08055 0
4559001 2023.05.19 16:57 1.08055 1.0806 1.08048 1.08056 0
4559002 2023.05.19 16:58 1.08055 1.08057 1.08055 1.08057 0
不太了解matlab,也不知道用python做什么来留下正确的数据。
我能做些什么来实现这一点?
编辑:
我试过这个:
TT=readtimetable('EURUSD_big_data.csv')
但出现此错误:
Expected a datetime or duration variable to use as RowTimes. Check that the data can
be converted to datetime or duration, or supply a "TimeStep" or "SampleRate".
如何使用
TimeStep
在这个例子中?
3条答案
按热度按时间zpqajqem1#
既然你有一个看起来很大的pandasDataFrame,你可以使用
mfinance
。我将绘制一个在文档中找到的数据集(* 与您的格式匹配,但有更多的行来选择一段时间--通过使用部分字符串索引 *--),以获得有意义的可视化。输出:
r6hnlfcb2#
在matlab中,可以通过使用
首先,你需要在python中创建一个DataFrame,将time设置为date time:
在这之后,你必须索引时间
并将df传递给csv
一旦你有了CSV,在MATLAB中
读取csv并使其成为表
把table整理好
删除NaN行(& D)
busg9geu3#
我不认为这件事有太多的复杂性。编写一个带有时间列的CSV文件并将其读入matlab
https://www.mathworks.com/help/matlab/ref/readtimetable.html(可能会在某个时间死亡...)
编辑:
接受你所尝试的。你已经OUTPUT了dataframe的index列。这是作为你的日期时间列读到时间表。手动删除该列(更痛苦),或者更改输出代码,使其不保存索引列--我认为这是错误的。
您可能还需要使用datetime库或类似的库将日期和时间列组合成datetime列-或作为时间戳/epochs。
还要注意的是,table 2 timestimate不能解决你的问题,因为你没有一个列可以作为采样率、时间戳、日期时间等。您必须首先修复数据集输出格式,然后才能修复使用
或