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

标签 python pandas

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

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/

相关文章:

pandas - 如果数据框中某些列大于另一个值并按另一列分组,则计算行数

Python Pandas 日期索引

python - Jupyter - 从导入的笔记本导入类

python - 如何将列表与数据框的列进行比较,并在数据框列和列表之间的元素匹配时从列表中删除元素?

python - 如何使列表中的每个对象都成为 float

python - 在 scipy chisquare : Don't know why? 中获取 p 值的 nan

python - for循环中的.Split()不返回列表

python pandas 删除系列中的重复项

python - 取消线程中的任务执行并从队列中删除任务

python - Pygame 窗口显示空白黑屏