学习中心 /编程 /NumPy /进阶提高 /搜索与排序
🔢 NumPy 进阶提高 💾 下载配套软件

搜索与排序

where、argmax、sort。

📅 2026-11-23 👁 16 次阅读

本节要解决的问题

where、argmax、sort。

核心要点

  • where 按条件返回索引
  • argmax 返回最大值位置
  • sort 返回排序后的数组
a = np.array([3, 1, 2])\nprint(a.argmax())\nprint(np.sort(a))
np.where 也能做条件替换,功能比看着强。