python将excel读取的日期文本数字转为日期(5位数字时间戳)

1.安装pandas:   pip install pandas  或    pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple 

2.将“44042”转为“2020-07-30”脚本

a = "44042"
import pandas as pd
def date(stamp):
    delta = pd.Timedelta(str(stamp)+'D')
    real_time = pd.to_datetime('1899-12-30') + delta
    return real_time

print(str(date(a)).split(" ")[0])

3.注意时pandas不是panda

 
原文地址:https://www.cnblogs.com/jingzaixin/p/13447942.html