NumPy is the fundamental package for scientific computing with Python.
Importing NumPy:
import numpy as np
A concise reference guide to essential NumPy operations for scientific computing in Python. Covers array creation, manipulation, indexing, and common mathematical and statistical functions.
|
NumPy is the fundamental package for scientific computing with Python. Importing NumPy:
|
|
|
From a text file. |
|
|
From a CSV file, handles missing values. |
|
|
Writes array |
|
|
Writes array |
|
|
One-dimensional array.
|
|
|
Two-dimensional array.
|
|
|
1D array of length 3 with all values 0.
|
|
|
3x4 array with all values 1.
|
|
|
5x5 identity matrix (1 on diagonal, 0 elsewhere).
|
|
|
Array of 6 evenly spaced values from 0 to 100.
|
|
|
Array of values from 0 up to (but not including) 10, with step 3.
|
|
|
2x3 array with all values 8.
|
|
|
4x5 array of random floats between 0 and 1. |
|
|
6x7 array of random floats between 0 and 100. |
|
|
2x3 array with random integers between 0 (inclusive) and 5 (exclusive).
|
|
|
Returns the total number of elements in |
|
|
Returns the dimensions of
|
|
|
Returns the data type of the elements in |
|
|
Converts the elements of |
|
|
Converts
|
|
|
View documentation for a specific NumPy function. |
|
|
Creates a deep copy of |
|
|
Creates a new view of |
|
|
Sorts
|
|
|
Sorts |
|
|
Flattens a 2D array |
|
|
Transposes
|
|
|
Reshapes |
|
|
Changes the shape of |
|
|
Appends |
|
|
Inserts
|
|
|
Deletes the row at index 3 from |
|
|
Deletes the column at index 4 from |
|
|
Adds
|
|
|
Adds
|
|
|
Splits |
|
|
Splits |
|
|
Stack arrays vertically (row wise) - Equivalent to |
|
|
Stack arrays horizontally (column wise) - Equivalent to |
|
|
Returns the element at index 5 (for 1D array). |
|
|
Returns the element at row index 2 and column index 5 (for 2D array). |
|
|
Assigns the value 4 to the element at index 1. |
|
|
Assigns the value 10 to the element at row index 1 and column index 3. |
|
|
Returns a slice containing elements from index 0 up to (but not including) index 3. |
|
|
Returns a slice containing elements from rows 0, 1, 2 at column 4. |
|
|
Returns a slice containing elements from the beginning up to (but not including) index 2. |
|
|
Returns a slice containing elements at index 1 from all rows (i.e., the second column).
|
|
|
Returns a boolean array of the same shape as |
|
|
Returns a boolean array based on combined conditions using logical operators ( |
|
|
Inverts a boolean array. |
|
|
Returns a 1D array containing only the elements from |
|
|
Element-wise addition of |
|
|
Element-wise subtraction of |
|
|
Element-wise multiplication of |
|
|
Element-wise division of |
|
|
Element-wise raise |
|
|
Calculates the square root of each element in |
|
|
Trigonometric functions applied element-wise. |
|
|
Natural logarithm and base-10 logarithm element-wise. |
|
|
Calculates the absolute value of each element in |
|
|
Rounds up to the nearest integer element-wise. |
|
|
Rounds down to the nearest integer element-wise. |
|
|
Rounds to the nearest integer element-wise. |
|
|
Adds 1 to each element in |
|
|
Subtracts 2 from each element in |
|
|
Multiplies each element in |
|
|
Divides each element in |
|
|
Raises each element in |
|
|
Returns the mean (average) of all elements in |
|
|
Returns the mean along a specific axis (e.g., column-wise for axis=0).
|
|
|
Returns the sum of all elements in |
|
|
Returns the sum along a specific axis. |
|
|
Returns the minimum value in |
|
|
Returns the minimum value along a specific axis. |
|
|
Returns the maximum value in |
|
|
Returns the maximum value along a specific axis. |
|
|
Returns the variance of |
|
|
Returns the standard deviation of |
|
|
Returns the standard deviation along a specific axis. |
|
|
Returns the correlation coefficient matrix of |
|
|
Calculates the median of |
|
|
Returns |
|
|
Element-wise comparison operators. Return boolean arrays. |