Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

A visual comparison of a NumPy array's contiguous memory block against a Python list's scattered object references.
Python

NumPy Array vs Python List: Performance Tradeoffs

Compare NumPy arrays and Python lists on speed, memory, vectorization, and typical workloads. See when each data structure is the better fit.

NumPyPython ListsPerformanceVectorization
Illustration of a NumPy array being saved to a CSV file and a binary .npy file, showing two storage paths.
Python

Python NumPy Save and Load: CSV and Binary Arrays

Save and load NumPy arrays as CSV text or binary .npy files. See practical code examples and tradeoffs for np.savetxt, np.loadtxt, np.save, np.load, and np.savez.

NumPyCSVBinary ArraysData Persistence
Diagram showing two NumPy arrays sharing one memory buffer versus two arrays with separate buffers, illustrating the copy versus view distinction.
Python

Python NumPy Copy vs View: Memory Sharing Explained

Learn how NumPy decides whether an operation returns a copy or a view, how to detect which one you have, and how mutation and memory usage behave.

numpypython arraysmemory managementarray mutation
Illustration of a NumPy array being converted from one data type to another, showing the dtype label changing.
Python

How to Use NumPy dtype and astype for Type Conversion

Learn how to use NumPy dtype and astype for array type conversion, including numeric, string, and datetime conversions, copy behavior, and common pitfalls.

NumPydata typestype conversionastype
A visual metaphor for NumPy NaN handling showing an array with missing values being filtered and replaced.
Python

NumPy NaN Detection, Replacement, and Removal

Detect, replace, and remove NaN values in NumPy arrays using np.isnan, np.nan_to_num, boolean indexing, and nan-aware aggregation functions.

NumPyNaNdata cleaningarray operations
Illustration of NumPy random seed initialization showing deterministic random number streams branching from a single seed node.
Python

Python NumPy Random Seed Choice and Random Numbers

python numpy random seed choice and random numbers: Learn how to use np.random.seed() and default_rng() in NumPy, choose seed values, and keep random number generation...

numpyrandom-seedreproducibilityrandom-number-generation
Illustration of NumPy broadcasting showing a 3x1 array and a 1x4 array expanding to a 3x4 result.
Python

NumPy Broadcasting and Vectorization

Understand how NumPy broadcasting and vectorization work, why they speed up array operations, and how to use them to replace Python loops with concise array expressions.

numpybroadcastingvectorizationarray operations
Illustration of matrix multiplication with NumPy showing two matrices combining into a result matrix.
Python

Python NumPy Dot Product and Matrix Multiplication Basics

python numpy dot product matrix multiplication and linear algebra basics: Learn how to use NumPy's dot product and matrix multiplication functions for linear algebra o...

numpylinear algebramatrix multiplicationdot product
A visual representation of NumPy array statistics showing mean, median, sum, variance, and standard deviation calculations.
Python

Python NumPy Mean, Median, Sum, Variance, and Standard Deviation

Compute mean, median, sum, variance, and standard deviation with Python NumPy. Covers axis handling, sample vs population variance, NaN-aware functions, dtype overflow, and empty arrays.

numpystatisticsdata-analysisvectorization
A visual representation of NumPy array sorting and filtering operations with arrows and data points.
Python

Python NumPy Sort, Unique, Search, and Filtering

Learn how to sort arrays, find unique values, search for elements, and filter data with NumPy's core functions, including practical examples and performance tradeoffs.

NumPyarray manipulationdata analysissorting