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 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短