Od listy Pythona do ndarray
Dowiedz się, dlaczego tablice liczbowe są lepsze od list.
Od listy Pythona do ndarray to bezpłatna lekcja Data Science Academy na CoddyKit. To lekcja 1 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Data Science Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Data Science Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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 float64Why 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 8Same 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. 🎉
Często zadawane pytania
Czy lekcja „Od listy Pythona do ndarray” jest bezpłatna?
Tak — pełny tekst „Od listy Pythona do ndarray” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Data Science Academy, przejdź na CoddyKit PRO. Kurs Data Science Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Od listy Pythona do ndarray”?
Dowiedz się, dlaczego tablice liczbowe są lepsze od list. Ćwiczysz Data Science Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Data Science Academy?
Nie wymagamy żadnego doświadczenia. Data Science Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 1 z 4.
Ile czasu zajmuje lekcja „Od listy Pythona do ndarray”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Data Science Academy?
Tak. Każda lekcja Data Science Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Od listy Pythona do ndarray
- Shape, size i dtype
- Wektoryzowana matematyka bez pętli
- Indeksowanie i wycinanie tablic