如何获取 NumPy np.datetime64 对象的单位/分辨率
NumPy 的 datetime64 对象表示为 64 位整数(这就是名称中 64 的含义)。
为了找出分辨率(例如 us、ns 等),首先使用以下命令安装我的 Python 3 UliEngineering 库
install_uliengineering.sh
pip install -U UliEngineering然后像这样使用 UliEngineering.Utils.NumPy 中的 datetime64_unit():
datetime64_resolution_example.py
from UliEngineering.Utils.NumPy import *
my_datetime = datetime64_now()
print(datetime64_resolution(my_datetime)) # 打印 "us"Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow