In [31]:
import numpy as np
import pandas as pd

a1 = np.array([1,2,3,4,5])
a1
a1.shape
a1.ndim


Out[31]:
1

In [8]:
x1=np.array([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])

x1[5::-2]
x1


Out[8]:
array([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])

In [23]:
x = np.array([1, 2, 3, 4, 5])

r1=x<3
list(r1)


Out[23]:
[True, True, False, False, False]

In [26]:
x[x<3]


Out[26]:
array([1, 2])

In [32]:
pd.Series({2:'a', 1:'b', 3:'c'}, index=[3, 2])


Out[32]:
3    c
2    a
dtype: object

In [47]:
rng = np.random.RandomState(42)
rng.randint(1,10,5)
rng.randint(0, 10, (3, 4))


Out[47]:
array([[9, 2, 6, 7],
       [4, 3, 7, 7],
       [2, 5, 4, 1]])

In [59]:
A = rng.randint(10, size=(3, 4))
print(A)
print(A-A[0])


[[3 8 2 4]
 [2 6 4 8]
 [6 1 3 8]]
[[ 0  0  0  0]
 [-1 -2  2  4]
 [ 3 -7  1  4]]

In [62]:
df = pd.DataFrame(A, columns=list('QRST'))
df - df.iloc[0]


Out[62]:
Q R S T
0 0 0 0 0
1 -1 -2 2 4
2 3 -7 1 4

In [63]:
df.subtract(df['R'], axis=0)


Out[63]:
Q R S T
0 -5 0 -6 -4
1 -4 0 -2 2
2 5 0 2 7

In [66]:
df.subtract(df.iloc[0], axis=1)


Out[66]:
Q R S T
0 0 0 0 0
1 -1 -2 2 4
2 3 -7 1 4