Converting Matlab's datenum format to Python

后端 未结 5 1741
甜味超标
甜味超标 2020-12-01 12:59

I just started moving from Matlab to Python 2.7 and I have some trouble reading my .mat-files. Time information is stored in Matlab\'s datenum format. For those who are not

5条回答
  •  失恋的感觉
    2020-12-01 13:29

    Here's a way to convert these using numpy.datetime64, rather than datetime.

    origin = np.datetime64('0000-01-01', 'D') - np.timedelta64(1, 'D')
    date = serdate * np.timedelta64(1, 'D') + origin
    

    This works for serdate either a single integer or an integer array.

提交回复
热议问题