Reputation: 35
from text '2010-09-02 00:00:00'
want to make as float type year like 2010.7xxx
How can I do it?
with Python 3.xx
Upvotes: 2
Views: 144
Reputation: 169494
You can use PyAstronomy
which has https://pyastronomy.readthedocs.io/en/latest/pyaslDoc/aslDoc/decimalYear.html#PyAstronomy.pyasl.decimalYear
pip install PyAstronomy
Then:
In [1]: from PyAstronomy import pyasl
In [2]: import datetime as dt
In [3]: d = dt.datetime(2010,9,2,0,0,0)
In [4]: pyasl.decimalYear(d)
Out[4]: 2010.668493150685
Upvotes: 2