python - NumPy 中的 ndarray 和数组有什么区别?

ndarray 和有什么区别?和 array在 NumPy 中?它们在 NumPy 源代码中的实现在哪里?

最佳答案

numpy.Array 只是创建 ndarray 的便利功能;它本身不是一个类。

您还可以使用 numpy.ndarray 创建一个数组,但这不是建议的方式。来自 numpy.ndarray 的文档字符串:

Arrays should be constructed using array, zeros or empty ... The parameters given here refer to a low-level method (ndarray(...)) for instantiating an array.

实现的大部分内容都在 C 代码中,here in multiarray ,但您可以从这里开始查看 ndarray 接口(interface):

https://github.com/numpy/numpy/blob/master/numpy/core/numeric.py

https://stackoverflow.com/questions/15879315/

相关文章:

linux - 如何找出文本文件中的行尾?

linux - 在亚马逊云服务器上设置 FTP

python - 在 Python 中计算字典中不同键的数量

python - 有哪些好的 Python ORM 解决方案?

python - 如何找到已安装的 pandas 版本

python - 将 timedelta 转换为天、小时和分钟

python - 如何更新 Python 包?

linux - 如何使用 bash 命令创建 CPU 峰值

regex - 如何在 find 命令中使用正则表达式?

python - 如何在管道中使用 `subprocess` 命令