ford345-lc09780:~ ssheehan$ python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy as np
 
>>> X = np.array([[4,2,3],[6,7,2]])

>>> X
array([[4, 2, 3],
       [6, 7, 2]])

>>> X[0][1] 		# first row, second column
2

>>> X[0,1]  		# same result as above
2

>>> X[0]			# first row of X
array([4, 2, 3])

>>> X[:,0]		# first column of X
array([4, 6])

>>> X.shape
(2, 3)

>>> Y = X[:,0]	# store first column as Y

>>> Y.shape		
(2,)

>>> Z = X[0]		# store first row as Z

>>> Z.shape
(3,)

>>> Z.T			# transpose of Z looks the same as Z and has same shape
array([4, 2, 3])

>>> np.dot(X[0],X[1])		# dot product of rows of X
44

>>> np.dot(X[0],Y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: shapes (3,) and (2,) not aligned: 3 (dim 0) != 2 (dim 0)

>>> np.dot(X[:,1],Y)
50

>>> X[:,1:]
array([[2, 3],
       [7, 2]])

>>> W = np.zeros((1,3))		# array of 0’s with shape (1,3), different than (3,)

>>> np.concatenate((X,W))	# this works because X and W have the same number of rows
array([[ 4,  2,  3],
       [ 6,  7,  2],
       [ 0,  0,  0]])

>>> np.concatenate((X,X[0]))	# this does not work because X is a 2d array and X[0] is 1d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: all the input arrays must have same number of dimensions

>>> np.concatenate((X,X[:,0:1]),axis=1)	# this works because the slicing maintains a second dimension
array([[4, 2, 3, 4],
       [6, 7, 2, 6]])

>>> W = X[0].reshape((1,3))	# we can get around this issue by using “reshape”

>>> W.shape
(1, 3)

>>> np.concatenate((X,W))		# now we can concatenate X and the first row of X
array([[4, 2, 3],
       [6, 7, 2],
       [4, 2, 3]])