AC
AnkiCollab
AnkiCollab
Sign in
Explore Decks
Helpful
Join Discord
Download Add-on
Documentation
Leave a Review
Notes in
Week 5 - NumPy
To Subscribe, use this Key
butter-alpha-low-indigo-seventeen-black
Status
Last Update
Fields
Published
11/26/2024
The {{c1::ndarray}} is a NumPy object representing a fast, flexible, multidimensional array.
Published
11/26/2024
{{c1::NumPy}} is a Python library for high-performance scientific computing and data analysis.
Published
11/26/2024
NumPy supports {{c1::memory-mapped files}}, allowing efficient reading/writing of array data on disk.
Published
11/26/2024
The basic import statement for NumPy is {{c1::import numpy as np}}.
Published
11/26/2024
To create a NumPy array from a list, use the function {{c1::np.array()}}.
Published
11/26/2024
The function {{c1::np.zeros()}} creates an array filled with zeros, given a specified shape.
Published
11/26/2024
To create an array with random values, use {{c1::np.random.rand()}}.
Published
11/26/2024
To change an array’s data type, use the {{c1::astype}} method.
Published
11/26/2024
{{c1::Broadcasting}} in NumPy allows operations on arrays of different shapes.
Published
11/26/2024
Array addition and multiplication in NumPy are {{c1::elementwise}} operations.
Published
11/26/2024
When arrays have different shapes, NumPy tries to align dimensions using {{c1::broadcasting}}.
Published
11/26/2024
Multiplying an array by a scalar applies the scalar to {{c1::each element}} in the array.
Published
11/26/2024
NumPy's {{c1::ufuncs}} perform elementwise operations, such as `np.add`, on arrays.
Published
11/26/2024
Slicing an array produces a {{c1::view}}, meaning changes to the slice affect the original array.
Published
11/26/2024
To create a copy of an array slice, use the {{c1::copy()}} method.
Published
11/26/2024
Fancy indexing allows selection of array elements in a {{c1::custom order}} using integer arrays.
Published
11/26/2024
For multidimensional arrays, an index of -1 accesses the {{c1::last element}} along an axis.
Published
11/26/2024
Slicing can be done along multiple axes by separating indices with a {{c1::comma}}.
Published
11/26/2024
Boolean indexing selects elements based on {{c1::condition arrays}}.
Published
11/26/2024
The {{c1::np.where}} function is a vectorized version of the ternary operation for element selection.
Published
11/26/2024
To set elements based on a condition, combine `np.where` with {{c1::assignment}}.
Published
11/26/2024
Conditions in NumPy use logical operators like {{c1::& (and)}} and {{c2::| (or)}} instead of `and` and `or`.
Published
11/26/2024
A boolean array of conditions can filter elements when indexing, producing an {{c1::array copy}}.
Published
11/26/2024
The {{c1::reshape}} function changes an array’s shape without altering the data.
Published
11/26/2024
To flatten a multidimensional array to a 1D array, use the {{c1::flatten()}} or {{c2::ravel()}} method.
Published
11/26/2024
The `.T` attribute transposes a matrix, swapping {{c1::rows and columns}}.
Published
11/26/2024
The {{c1::concatenate}} function joins arrays along an existing axis.
Published
11/26/2024
{{c1::np.sum}} and {{c2::np.mean}} calculate the sum and mean along a specified axis.
Published
11/26/2024
To calculate cumulative sums, use {{c1::np.cumsum}}, which returns partial sums along an axis.
Published
11/26/2024
The {{c1::axis}} argument specifies which axis to operate on in functions like `sum` or `mean`.
Published
11/26/2024
Using {{c1::np.std}} provides the standard deviation of an array’s elements.
Published
11/26/2024
{{c1::np.min}} and {{c2::np.max}} return the minimum and maximum values in an array.
Published
11/26/2024
Vectorization refers to using array expressions instead of {{c1::explicit loops}}.
Published
11/26/2024
A binary ufunc, such as `np.add`, operates on two arrays elementwise and returns {{c1::a single array}}.
Published
11/26/2024
For in-place operations, some ufuncs support an optional {{c1::out argument}}.
Published
11/26/2024
Matrix multiplication in NumPy uses the `@` operator or {{c1::np.dot}} function.
Published
11/26/2024
The {{c1::np.linalg}} module provides functions for matrix inversion and other operations.
Published
11/26/2024
The determinant of a matrix can be found using {{c1::np.linalg.det}}.
Published
11/26/2024
{{c1::Eigenvalues}} and eigenvectors of a matrix are calculated with `np.linalg.eig`.
Published
11/26/2024
The {{c1::transpose}} of a matrix exchanges its rows and columns.
Published
11/26/2024
To save an array in binary format, use {{c1::np.save}}.
Published
11/26/2024
The `np.savez` function saves multiple arrays into a single {{c1::zip archive}}.
Published
11/26/2024
To read an array saved with `np.save`, use {{c1::np.load}}.
Published
11/26/2024
For text file I/O, use {{c1::np.loadtxt}} to load data and {{c2::np.savetxt}} to save it.
Status
Last Update
Fields