NumPy ユーザーガイド
NumPyの包括的な入門概要および技術ガイド。インストール、配列操作、インデックス指定、ブロードキャスト、およびC/C++との統合について解説します。
コース概要
📚 コンテンツ概要
NumPyのインストール、配列操作、インデックス指定、ブロードキャスト、およびC/C++との統合をカバーする包括的な入門ガイドと技術マニュアル。
公式NumPyガイドで、Pythonにおける科学計算の基盤をマスターしよう。
著者: NumPyコミュニティ
謝辞: NumPyコミュニティが執筆
🎯 学習目標
- NumPyの定義を述べ、科学的Pythonエコシステムにおけるその役割を識別する。
- ベクトル化という概念を用いて、なぜNumPyが標準のPythonループよりもはるかに高速であるかを説明する。
- Pip、Conda、Raspberry Piなど、さまざまな環境向けのインストールコマンドを実行する。
ndarrayの核心的な属性(ndim、shape、dtype)を識別し、解釈する。linspace、reshape、vstack、hstackなどの関数を使用して配列の作成と操作を実行する。- 要素ごとの演算、ユニバーサル関数(ufuncs)、線形代数ソルバーを数値データセットに適用する。
- NumPyのスカラー型および情報ツール(
iinfo、finfo)を用いて、データ精度を管理し、オーバーフローのエラーを軽減する。 - カスタム区切り文字、ヘッダー、列選択を用いた
genfromtxtを活用して、柔軟なディスクからのデータ読み込みを実装する。 - さまざまな形状を持つ配列間の相互作用を予測・制御するために、一般ブロードキャスト規則を適用する。
.base属性を活用して、カスタムndarrayサブクラスにおけるメモリ参照の管理と「落とし穴」の回避を行う。
レッスン 共 5 课时 · 预计 15.0h
レッスン
Lesson
This lesson introduces NumPy as the foundational bridge between high-level Python applications and low-level hardware, focusing on the ndarray as a universal interface for scientific computing. Students will learn how the ndarray’s contiguous memory layout and homogeneous data structure enable high-performance, vectorized operations across the data science ecosystem.
This lesson introduces the NumPy ndarray as a memory-efficient, homogeneous alternative to Python lists, focusing on proper initialization and the performance benefits of contiguous memory. Students will learn to interpret core array attributes—such as shape, size, and data type—to understand how metadata defines the spatial geometry and memory footprint of numerical data.
This lesson covers precision management in NumPy, focusing on how fixed-size data types handle integer overflow and floating-point saturation. It also introduces robust data ingestion techniques using np.genfromtxt to handle irregular file formats and sanitize messy datasets.
This lesson explores the complexities of subclassing `numpy.ndarray`, focusing on the "Initialization Triad" and the critical role of the `__array_finalize__` hook in maintaining metadata. Students will learn to navigate the risks of behavioral fragility and identify when to choose subclassing for interoperability versus using composition for safer architectural design.
AI018: Extending NumPy with the C-API (Lesson 5) explores how to overcome performance bottlenecks like the interpreter tax and memory bloat by implementing high-performance C extensions. Students will learn to manage memory safely, utilize kernel fusion, and perform cache-aligned pointer arithmetic to optimize complex computational tasks.