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]:
In [8]:
x1=np.array([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])
x1[5::-2]
x1
Out[8]:
In [23]:
x = np.array([1, 2, 3, 4, 5])
r1=x<3
list(r1)
Out[23]:
In [26]:
x[x<3]
Out[26]:
In [32]:
pd.Series({2:'a', 1:'b', 3:'c'}, index=[3, 2])
Out[32]:
In [47]:
rng = np.random.RandomState(42)
rng.randint(1,10,5)
rng.randint(0, 10, (3, 4))
Out[47]:
In [59]:
A = rng.randint(10, size=(3, 4))
print(A)
print(A-A[0])
In [62]:
df = pd.DataFrame(A, columns=list('QRST'))
df - df.iloc[0]
Out[62]:
In [63]:
df.subtract(df['R'], axis=0)
Out[63]:
In [66]:
df.subtract(df.iloc[0], axis=1)
Out[66]: