gpt4 book ai didi

python - 从 np.datetime64 转换为 float 年份

转载 作者:行者123 更新时间:2023-12-04 10:12:25 24 4
gpt4 key购买 nike

来自文本“2010-09-02 00:00:00”

想要像 2010.7xxx 这样的浮点型年份

我该怎么做?

使用 Python 3.xx

最佳答案

您可以使用 PyAstronomy其中有 https://pyastronomy.readthedocs.io/en/latest/pyaslDoc/aslDoc/decimalYear.html#PyAstronomy.pyasl.decimalYear

pip install PyAstronomy

然后:
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

关于python - 从 np.datetime64 转换为 float 年份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61263524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com