gpt4 book ai didi

python - 如何在 Pandas 数据框中转换时间 2020-09-25T00 :20:00. 000Z

转载 作者:行者123 更新时间:2023-12-01 23:47:02 28 4
gpt4 key购买 nike

我的数据框中有以下格式的时间:

print(df)
Date
2020-09-25T00:20:00.000Z

两个问题:a) 这是什么格式?b) 如何创建一个包含澳大利亚时间 (AEDT) 日期和时间的新列。

任何帮助都会很棒!谢谢

最佳答案

这是什么格式?

检查 link :

The T doesn't really stand for anything. It is just the separator that the ISO 8601 combined date-time format requires. You can read it as an abbreviation for Time.
The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC).

如何使用澳大利亚时间 (AEDT) 的日期和时间创建新列?

将列转换为日期时间,然后使用 Series.dt.tz_convert :

df['Date'] = pd.to_datetime(df['Date']).dt.tz_convert('Australia/Sydney')
print (df)
Date
0 2020-09-25 10:20:00+10:00

关于python - 如何在 Pandas 数据框中转换时间 2020-09-25T00 :20:00. 000Z,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64023330/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com