Python provides very bare bones functionality for numeric analysis.
# Representing 3x3 matrix with list
mat = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
# Subsetting 2nd row, 3rd element
mat[1][2]
6
# Naturally, this representation
# breaks down rather quickly
mat * 2
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9]]
# Using 'as' allows to avoid typing full name
# each time the module is referred to
import numpy as np
arr = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
arr[1][2]
6
arr * 2
array([[ 2, 4, 6], [ 8, 10, 12], [14, 16, 18]])
# Object type
type(arr)
numpy.ndarray
# Array dimensionality
arr.ndim
2
# Array size
arr.shape
(3, 3)
# Calculating summary statistics on array
# axis indicates the dimension
# note that every list within a list
# is treated as a column (not row)
arr.mean(axis = 0)
array([4., 5., 6.])
Source: R for Data Science