0Pricing
Data Science Academy · Aula

De uma lista Python a ndarray

Entenda por que matrizes superam listas para números.

De uma lista Python a ndarray é uma aula grátis de Data Science Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Data Science Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Data Science Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Meet the ndarray

NumPy's core gift is the ndarray, a grid of numbers all of one type. It is the workhorse behind almost every data tool you'll use. 🚀

Lists Are Flexible but Slow

A Python list can hold anything: numbers, strings, even other lists. That freedom is handy, but for crunching numbers it makes the list slow.

Arrays Are Fast and Strict

An array trades flexibility for speed. Every element shares one dtype, so NumPy stores them tightly and computes on them at near-C speed.

Your First Array

You build an array by passing a list to np.array. NumPy reads the values and wraps them into a fast numeric grid for you.

import numpy as np
arr = np.array([1, 2, 3, 4])

One Type Rules Them All

Mix an int and a float in one array and NumPy quietly promotes everything to float, because all elements must share a single type.

np.array([1, 2, 3.5])  # becomes float64

Why Speed Comes Free

Because the type is fixed, NumPy skips the per-item checks a list needs. This vectorization is why arrays fly through millions of numbers. ⚡

Arrays Live in One Block

List items scatter across memory, but an array sits in one contiguous block. Your CPU loves that, reading values in tight, predictable bursts.

Make Arrays From Scratch

You don't always start from a list. np.zeros and np.ones fill an array with a chosen value, perfect for placeholders you fill in later.

np.zeros(5)   # array([0., 0., 0., 0., 0.])

Ranges the NumPy Way

Need an even sequence? np.arange works like Python's range but hands you back an array ready for math.

np.arange(0, 10, 2)  # 0 2 4 6 8

Same Idea, Bigger Dimensions

An array isn't limited to one row. Pass nested lists and you get a 2D grid, the matrix shape that powers tables and images.

np.array([[1, 2], [3, 4]])

The Foundation of Everything

pandas, scikit-learn, and matplotlib all sit on top of the ndarray. Master this one type and the whole data stack opens up. 🧱

Quick Check

Let's check the key difference between lists and arrays.

Recap

You met the ndarray: a single-type, tightly packed grid that beats lists for numbers. Build it with np.array, zeros, or arange, then let the speed work for you. 🎉

Perguntas Frequentes

A aula “De uma lista Python a ndarray” é grátis?

Sim — o texto completo de “De uma lista Python a ndarray” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Data Science Academy, atualize para CoddyKit PRO. O curso de Data Science Academy inclui 4 aulas no total.

O que vou aprender em “De uma lista Python a ndarray”?

Entenda por que matrizes superam listas para números. Você pratica Data Science Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Data Science Academy?

Nenhuma experiência prévia é necessária. Data Science Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “De uma lista Python a ndarray”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Data Science Academy?

Sim. Cada aula de Data Science Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. De uma lista Python a ndarray
  2. Forma, tamanho e dtype
  3. Matemática vetorizada sem laços
  4. Indexação e fatiamento de matrizes
← Voltar para Data Science Academy