In [1]:
from platform import python_version
In [2]:
python_version()
Out[2]:
In [3]:
import numpy as np
In [4]:
np.__version__
Out[4]:
In [5]:
myarray = np.array([1,2,3])
myarray[::-1]
Out[5]:
In [6]:
myarray = np.array([
[1,2,3],
[4,5,6],
[7,8,9]
])
myarray[::-1]
Out[6]:
In [7]:
# np.set_printoptions(edgeitems=3,infstr='inf',
# linewidth=75, nanstr='nan', precision=8,
# suppress=False, threshold=1000, formatter=None)
y=np.array([1.0e-10,1.0,100,1000])
y
Out[7]:
In [8]:
np.set_printoptions(suppress=True)
y
Out[8]:
In [9]:
myarray = np.array([
[1,2,3],
[4,5,6],
[7,8,9]
])
myarray
Out[9]:
In [10]:
myarray[:,1]
Out[10]:
In [11]:
myarray[0,:]
Out[11]:
In [12]:
x = np.array([
[1,2,3],
[4,5,6]
])
In [13]:
y = x.copy()
In [14]:
y.fill(1)
In [15]:
x
Out[15]:
In [16]:
y
Out[16]:
In [17]:
myarray = np.array([
[1,2,3],
[4,5,6]
])
In [18]:
newrow = np.array([9,9,9])
In [19]:
np.vstack([myarray,newrow])
Out[19]:
In [20]:
myarray = np.array([
[1,2,3],
[4,5,6]
])
In [21]:
newcol = np.array([[9],[9]])
In [22]:
np.hstack([myarray,newcol])
Out[22]:
In [28]:
a = np.array([1,2,3])
b = np.array([0,0,0])
np.array_equal(a,b)
Out[28]:
In [32]:
a = np.array([1,np.nan,3])
b = np.array([1,np.nan,3])
np.array_equal(a,b)
Out[32]:
In [33]:
a = np.array([1,np.nan,3])
b = np.array([1,np.nan,3])
np.allclose(a, b, equal_nan=True)
Out[33]:
In [30]:
a = np.array([1,2,3])
b = np.array([1,2,3])
np.array_equal(a,b)
Out[30]: