我想知道为什么datetime.datetime.timestamp
返回的结果与pd.to_datetime.timestamp
不同
这里是一个例子:
from datetime import datetime
import pandas as pd
now = datetime.now()
print(now.timestamp())
print(pd.to_datetime(now).timestamp())
# 1572490362.553197
# 1572472362.553197
答案 0 :(得分:0)
Bharath M是正确的:
import datetime
import pandas as pd
now = datetime.datetime.now(datetime.timezone.utc)
print(now.timestamp())
print(pd.to_datetime(now, utc=True).timestamp())
# 1572493959.718966
# 1572493959.718966