I\'m importing some data in a spreadsheet. It\'s in a dataframe, but the date is in a numerical representation or format
41516.43
First, I
Piecing together from another question:
In [11]: s = pd.Series([41516.43])
In [12]: from xlrd.xldate import xldate_as_tuple
In [13]: from datetime import datetime
In [14]: s.apply(lambda x: datetime(*xldate_as_tuple(x, 0)))
Out[14]:
0 2013-08-30 10:19:12
dtype: datetime64[ns]
Note: presumably slight difference is due to rounding of the float you gave.
and the "bare-knuckle no-seat-belts use-at-own-risk" version:
In [21]: pd.Timestamp('1899-12-30') + (pd.offsets.Day(1).nanos * s).astype(np.timedelta64)
Out[21]:
0 2013-08-30 10:19:12
dtype: datetime64[ns]
I think it's generally preferable to do parse dates while using read_excel.