时间序列数据重组
我正在编写一些可以重新排列时间序列的代码。目前我有一个标准时间序列。我有一个三列,标题为[日期、时间、值]。我想重新格式化数据帧以使用日期进行索引,并使用带有时间的标题(即 0:00、1:00、...、23:00)。数据框将填充该值。
这是当前的数据框
本质上,我想将索引移动到一天,并通过列显示小时数。
谢谢,
I am working on some code that will rearrange a time series. Currently I have a standard time series. I have a three columns with with the header being [Date, Time, Value]. I want to reformat the dataframe to index with the date and use a header with the time (i.e. 0:00, 1:00, ... , 23:00). The dataframe will be filled in with the value.
Here is the Dataframe currently have
essentially I'd like to mve the index toa single day and show the hours through the columns.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
pivot
:输出(前 10 列,
Total
具有随机值):Use
pivot
:Output (first 10 columns and with random values for
Total
):你可以试试这个。
拆分时间部分以仅获取小时。添加
hr
到其中。输出
You could try this.
Split the time part to get only the hour. Add
hr
to it.Output