I am looking for a way to convert datetime objects to decimal(/float) year, including fractional part. Example:
>>> obj = SomeObjet()
>>> o
It's possible to calculate decimal date by using Pandas's julian date and the following formulas.
In the case where your pandas dataframe has an index that is date-time:
JD=dat.index.to_julian_date() #create julian date
L= JD+68569
N= 4*L/146097
L= L-(146097*N+3)/4
I= 4000*(L+1)/1461001
L= L-1461*I/4+31
J= 80*L/2447
K= L-2447*J/80
L= J/11
J= J+2-12*L
decimal_date= 100*(N-49)+I+L
decimal_date is a series of your date (in the same TZ as the dataframe index) in form of something like 2007.123452.
Adapted from this post.