0% found this document useful (0 votes)
2 views2 pages

NumPy Functions Overview and Examples

The document provides an overview of NumPy functions and methods, including array creation, operations, manipulation, indexing, selection, and random number generation. It lists various functions with syntax examples for creating arrays, performing mathematical operations, reshaping, and accessing elements. Additionally, it covers random number generation techniques and setting seeds for reproducibility.

Uploaded by

sannydevi740
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

NumPy Functions Overview and Examples

The document provides an overview of NumPy functions and methods, including array creation, operations, manipulation, indexing, selection, and random number generation. It lists various functions with syntax examples for creating arrays, performing mathematical operations, reshaping, and accessing elements. Additionally, it covers random number generation techniques and setting seeds for reproducibility.

Uploaded by

sannydevi740
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NumPy Functions and Methods

Overview with Syntax Examples


Array Creation
 [Link]([1, 2, 3]): Creates an array from a list or tuple.
 [Link]((2, 3)): Creates a 2x3 array filled with zeros.
 [Link]((2, 3)): Creates a 2x3 array filled with ones.
 [Link]((2, 3)): Creates an uninitialized array.
 [Link](0, 10, 2): Creates an array [0 2 4 6 8].
 [Link](0, 1, 5): Creates an array [0. 0.25 0.5 0.75 1. ].
 [Link](3): Creates a 3x3 identity matrix.
 [Link]((2, 2), 7): Creates a 2x2 array filled with 7.

Array Operations
 arr1 + arr2: Element-wise addition.
 [Link](arr1, arr2): Calculates the dot product.
 [Link](arr1, arr2): Performs matrix multiplication.
 [Link](arr): Sum of all elements.
 [Link](arr): Mean of elements.
 [Link](arr): Median of elements.
 [Link](arr): Standard deviation.
 [Link](arr): Variance.
 [Link](arr), [Link](arr): Max and min values.
 [Link](arr), [Link](arr): Indices of max and min.
 [Link](arr): Square root of elements.
 [Link](arr): Exponential of elements.
 [Link](arr), np.log10(arr): Natural or base-10 logarithm.
Array Manipulation
 [Link](3, 2): Reshapes array to 3x2.
 arr.T: Transposes the array.
 [Link](): Flattens array to 1D.
 [Link](arr): Returns flattened array.
 [Link]([arr1, arr2], axis=0): Concatenates arrays.
 [Link]((arr1, arr2), axis=1): Stacks arrays along new axis.
 [Link]((arr1, arr2)): Horizontal stack.
 [Link]((arr1, arr2)): Vertical stack.
 [Link](arr, 3): Splits array into 3 parts.
 [Link](arr, 2): Repeats array twice.
 [Link](arr, 2): Repeats each element twice.

Array Indexing & Selection


 arr[0]: Access first element.
 arr[1:4]: Slice from index 1 to 3.
 [Link](arr > 0): Indices where condition is true.
 [Link](arr): Indices of non-zero elements.
 [Link](arr, [0, 2]): Extracts elements at indices 0 and 2.

Random Number Generation


 [Link](2, 3): Random floats in [0,1) in shape 2x3.
 [Link](0, 10, size=(3,)): Random integers from
0 to 9.
 [Link](3, 3): Standard normal distribution.
 [Link]([1, 2, 3], size=2): Randomly select
elements.
 [Link](42): Set random seed for reproducibility.

You might also like