NumPy Basics
Shared by a Flashcards.gg user · generated with AI · Report this set
This set covers essential NumPy functions and methods for data manipulation and scientific computing in Python.
Tap the card to flip it
Cards · 64
- np.array()
- Creates an N-dimensional array from an iterable like a list or tuple.
- ndarray.ndim
- Returns the number of array dimensions (axes).
- ndarray.shape
- Returns a tuple showing the size of the array along each dimension.
- ndarray.size
- Returns the total number of elements in the array.
- ndarray.dtype
- Describes the data type of the array elements.
- ndarray.itemsize
- Returns the length of one array element in bytes.
- np.zeros()
- Returns a new array of specified shape and type, filled with zeros.
- np.ones()
- Returns a new array of specified shape and type, filled with ones.
- np.empty()
- Creates an array of given shape without initializing entries to specific values.
- np.full()
- Returns a new array of given shape and type, filled with a specified fill value.
- np.arange()
- Returns evenly spaced values within a given interval, similar to Python range.
- np.linspace()
- Returns evenly spaced numbers over a specified interval, specifying count.
- np.eye()
- Returns a 2D array with ones along the diagonal and zeros elsewhere.
- np.identity()
- Returns a square identity array of given size.
- ndarray.astype()
- Copy of the array, cast to a specified data type.
- ndarray.reshape()
- Returns an array containing the same data with a new shape.
- ndarray.ravel()
- Returns a contiguous flattened 1D array view.
- ndarray.flatten()
- Returns a copy of the array collapsed into one dimension.
- ndarray.T
- Transposes the array, swapping axes.
- np.transpose()
- Reverses or permutes the axes of an array.
- np.concatenate()
- Joins a sequence of arrays along an existing axis.
- np.stack()
- Joins a sequence of arrays along a new axis.
- np.vstack()
- Stacks arrays vertically along rows.
- np.hstack()
- Stacks arrays horizontally along columns.
- np.split()
- Splits an array into multiple sub-arrays along a specified axis.
- np.squeeze()
- Removes single-dimensional entries from the shape of an array.
- np.expand_dims()
- Expands the shape of an array by inserting a new axis.
- ndarray.copy()
- Returns a deep copy of the array.
- ndarray.view()
- Creates a new view of the array data without copying it.
- np.sum()
- Computes the sum of array elements over a specified axis or all elements.
- np.mean()
- Computes the arithmetic mean along the specified axis.
- np.median()
- Computes the median value along the specified axis.
- np.std()
- Computes the standard deviation along the specified axis.
- np.var()
- Computes the variance along the specified axis.
- np.min()
- Returns the minimum value of an array or along an axis.
- np.max()
- Returns the maximum value of an array or along an axis.
- np.argmin()
- Returns the indices of the minimum values along an axis.
- np.argmax()
- Returns the indices of the maximum values along an axis.
- np.cumsum()
- Returns the cumulative sum of elements along a given axis.
- np.cumprod()
- Returns the cumulative product of elements along a given axis.
- np.clip()
- Limits the values in an array between a minimum and maximum threshold.
- np.abs()
- Calculates the absolute value element-wise.
- np.sqrt()
- Calculates the non-negative square root of each element.
- np.exp()
- Calculates the exponential of all elements in the input array.
- np.log()
- Computes the natural logarithm element-wise.
- np.round()
- Rounds elements of an array to the given number of decimals.
- np.dot()
- Computes the dot product of two arrays.
- np.matmul()
- Computes the matrix product of two arrays.
- np.where()
- Returns elements chosen from x or y depending on a condition.
- np.select()
- Returns an array drawn from elements in choicelist, based on conditions.
- np.unique()
- Finds the unique elements of an array.
- np.sort()
- Returns a sorted copy of an array.
- np.argsort()
- Returns the indices that would sort an array.
- np.all()
- Tests whether all array elements along a given axis evaluate to True.
- np.any()
- Tests whether any array elements along a given axis evaluate to True.
- np.isnan()
- Tests element-wise for NaN and returns a boolean array.
- np.isinf()
- Tests element-wise for positive or negative infinity.
- np.random.rand()
- Creates an array of specified shape with uniform random samples over [0, 1).
- np.random.randn()
- Returns samples from the standard normal distribution.
- np.random.randint()
- Returns random integers from low (inclusive) to high (exclusive).
- np.random.choice()
- Generates a random sample from a given 1D array.
- np.random.seed()
- Initializes the random number generator for reproducible outputs.
- np.save()
- Saves an array to a binary file in NumPy .npy format.
- np.load()
- Loads arrays or pickled objects from .npy, .npz, or pickled files.