使用思路为:Timestamp
->字符串
->datetime.datetime
示例代码
import pandas as pd
from datetime import datetime
def convert_timestamp(this_date):
"""转Timestamp为datetime.datetime"""
target_date = datetime.strptime(this_date.strftime("%Y-%m-%d"), "%Y-%m-%d")
return target_date
new_date = convert_timestamp(this_date=pd.to_datetime("2022-01-01"))
print(new_date, type(new_date))
得到结果:
2022-01-01 00:00:00 <class 'datetime.datetime'>