1、to_datetime中的unit参数只能运用于前面的数值为整数或者浮点数,转换结果是一个日期类型。
pd.to_datetime(18263 , unit="D")
# Timestamp('2020-01-02 00:00:00')
2、通过to_numeric将时间转换为整型,最后转换为天数
# 日期默认 ns
# downcast {‘integer’, ‘signed’, ‘unsigned’, ‘float’} 可指定转换后的类型
df['date'] = pd.to_numeric(df['date'])
df['date'] = df['date'].apply(lambda x: x/(1e9 * 60 * 60 * 24))
# 0 18263.0
# 1 19428.0
# Name: dt, dtype: float64