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