Member-only story

Python: NumPy Basics

Jayesh Rao
2 min readJul 27, 2021

--

Numpy works in a lower level language and therefore has shorter computational times.

Deals with vectors and matrices.

Can be used to import and preprocess data into Python directly.

Main feature: N-D array class which corresponds to lists.

Matrix: A datastructure having rows and columns used mostly for mathematical operations. A collection of vectors.

Scalar: A single element. All the numbers from algebra are refered to as scalars in linear algebra.

Vector: Single dimensional object. Vector can be a column or row vector.

#vector operations

np.append(vector,new_value/vector2) #add new values to the vector

vector[index] = new_value #update existing value

del v[0] #cannot delete array elements

Declaring a matrix, vector and scalar

import numpy as np

np.array([[[ 1, -3, 245],[ 0, -2, 246]], [[ 1, 3, 2],[ 3, 49, 77]]]) #gives tensor

np.array([[1,2,3],[4,5,6],[7,8,9]]) #gives 3X3 matrix

np.array([1,2,3]) #gives vector

np.array([4]) #gives scalar

--

--

Jayesh Rao
Jayesh Rao

Written by Jayesh Rao

Hi good to see y'all, I am an aspiring data analyst and will be posting stuff about Statistics, Python and R and also some interesting projects I do. B-)

No responses yet

Write a response