嗨,我有一个这样的df:
Timestamp | Price |
2019-04-30T11:00:00 | 5150 |
2019-04-30T12:00:00 | 5185 |
2019-04-30T13:00:00 | 5212 |
2019-04-30T14:00:00 | 5211 |其中typeof(df$Timestamp)返回"character"
如何将时间戳前移8小时?预期结果:
Timestamp | Price |
2019-04-30T19:00:00 | 5150 |
2019-04-30T20:00:00 | 5185 |
2019-04-30T21:00:00 | 5212 |
2019-04-30T22:00:00 | 5211 |发布于 2021-05-04 00:08:49
我们可以转换为datetime类并添加hours
library(lubridate)
df1$Timestamp <- ymd_hms(df1$Timestamp) + hours(8)数据
df1 <- structure(list(Timestamp = c("2019-04-30T11:00:00", "2019-04-30T12:00:00",
"2019-04-30T13:00:00", "2019-04-30T14:00:00"), Price = c(5150L,
5185L, 5212L, 5211L)), class = "data.frame", row.names = c(NA,
-4L))https://stackoverflow.com/questions/67372160
复制相似问题