Python Pandas - 返回表示 UTC 日期和时间的 Timestamp
要返回一个表示 UTC 日期和时间的新 Timestamp,请使用 timestamp.utcnow() 方法。首先,导入所需的库 −
import pandas as pd
创建一个 Timestamp
timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC')
带有 UTC 日期和时间的新 Timestamp
timestamp.utcnow()
范例
以下为代码
import pandas as pd
# creating a timestamp
timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC')
# display the Timestamp
print("Timestamp...\n", timestamp)
# new timestamp with UTC day and time
print("\nUTC day and time...\n", timestamp.utcnow())输出
将生成以下代码
Timestamp... 2021-10-16 15:12:34.261811624+00:00 UTC day and time... 2021-10-03 07:56:08.901294+00:00
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP