我有多个 csv 文件,我已将 DateTime 设置为索引。
df6.set_index("gmtime", inplace=True)
#correct the underscores in old datetime format
df6.index = [" ".join( str(val).split("_")) for val in df6.index]
df6.index = pd.to_datetime(df6.index)
Run Code Online (Sandbox Code Playgroud)
时间设置为 GMT,但我认为当我为树莓派设置时钟时,它已被保存为 BST(英国夏令时)。我想把时间向后拨一小时。当我使用
df6.tz_convert(pytz.timezone('utc'))
Run Code Online (Sandbox Code Playgroud)
它给了我以下错误,因为它假设时间是正确的。
无法转换 tz-naive 时间戳,请使用 tz_localize 进行本地化
如何将时间改为一小时?