如何修复 NumPy timedelta64 TypeError: Invalid datetime unit "min" in metadata
问题:
你想使用以下命令从分钟值构造 NumPy timedelta64
example.py
np.timedelta64(1, 'min')但你看到类似这样的错误消息
output.txt
Traceback (most recent call last):
File "test.py", line 3, in <module>
delta = np.timedelta64(1, 'min')
TypeError: Invalid datetime unit "min" in metadata解决方案
numpy 使用 m 作为 minutes 的指定符,而不是 min!将你的代码更改为
example_fixed.py
np.timedelta64(1, 'm')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