Guia do Usuário do NumPy
Uma visão geral introdutória e guia técnico completo do NumPy, cobrindo instalação, manipulação de matrizes, indexação, broadcast e integração com C/C++.
Visão Geral do Curso
📚 Resumo do Conteúdo
Uma visão introdutória abrangente e um guia técnico sobre o NumPy, cobrindo instalação, manipulação de arrays, indexação, transmissão (broadcasting) e integração com C/C++.
Domine a base do cálculo científico em Python com o guia oficial do NumPy.
Autor: A Comunidade NumPy
Agradecimentos: Escrito pela comunidade NumPy
🎯 Objetivos de Aprendizagem
- Definir o NumPy e identificar seu papel no ecossistema científico do Python.
- Explicar por que o NumPy é significativamente mais rápido que loops padrão do Python usando o conceito de vetorização.
- Executar comandos de instalação para diversos ambientes, incluindo Pip, Conda e Raspberry Pi.
- Identificar e interpretar atributos principais do
ndarray, comondim,shapeedtype. - Executar criação e manipulação de arrays usando funções como
linspace,reshape,vstackehstack. - Aplicar operações elementares, funções universais (ufuncs) e solucionadores de álgebra linear a conjuntos de dados numéricos.
- Gerenciar precisão de dados e mitigar erros de estouro usando tipos escalares do NumPy e ferramentas de informação (
iinfo,finfo). - Implementar ingestão flexível de dados do disco usando
genfromtxtcom delimitadores personalizados, cabeçalhos e seleção de colunas. - Aplicar as Regras Gerais de Broadcasting para prever e controlar interações entre arrays de formas diferentes.
- Gerenciar referências de memória e evitar "armadilhas" em subclasses personalizadas de
ndarrayusando o atributo.base.
Aulas 共 5 课时 · 预计 15.0h
Aulas
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.