computing the mean for python datetime

前端 未结 5 587
梦谈多话
梦谈多话 2020-12-21 00:32

I have a datetime attribute:

d = {
    \'DOB\': pd.Series([
        datetime.datetime(2014, 7, 9),
        datetime.datetime(2014, 7, 15),
        np.datetim         


        
5条回答
  •  执念已碎
    2020-12-21 01:04

    You can convert epoch time using astype with np.int64 and converting back to datetime with pd.to_datetime:

    pd.to_datetime(df_test.DOB.dropna().astype(np.int64).mean())
    

    Output:

    Timestamp('2014-07-12 00:00:00')
    

提交回复
热议问题