Python Pandas - 将时间戳转换为另一个时区
将时间戳转换为另一个时区,使用.将时区设置为参数。首先,导入所需的库-timestamp.tz_convert()
import pandas as pd
在Pandas中创建时间戳对象。我们还设置了时区
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')转换时间戳的时区
timestamp.tz_convert('Australia/Brisbane'))示例
以下是代码
import pandas as pd
#setthetimestampobjectinPandas
#wehavealsosetthetimezone
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')
#displaytheTimestamp
print("Timestamp...\n", timestamp)
#converttimezone
print("\nConvert the Timestamp timezone...\n",
timestamp.tz_convert('Australia/Brisbane'))输出结果这将产生以下代码
Timestamp... 2021-10-14 15:12:34.261811624-04:00 Convert the Timestamp timezone... 2021-10-15 05:12:34.261811624+10:00
热门推荐
10 中午祝福语简短句子
11 男孩中考蛋糕祝福语简短
12 要庆祝生日祝福语简短
13 默克尔离职祝福语简短
14 开工红包祝福语毕业简短
15 3.8祝福语简短的词语
16 新婚祝福语英语简短精辟
17 送给新娘祝福语简短高级
18 对银行的祝福语简短