import numpy as np
data = np.array([[1, 1.5, 2], [5, 3, 1]])
data
data.shape
data.dtype
data.ndim
np.zeros((3, 6))
np.empty((2, 4))
np.arange(10)
np.arange(10, dtype = np.float64)
np.arange(10, dtype = 'float64').dtype
a1 = np.array([1, 2, 3, 4.5], dtype=np.float64)
a1
a1.dtype
a2 = a1.astype(np.int64)
a2
a2.dtype
a1 = np.array([1, 2, 3, 4])
a1 * a1
a1 + a1
1 / a1
a1 ** 4
a2 = np.array([4, 3, 2, 1])
a1 > a2
a3 = np.arange(10, 7, -0.25)
a3
a1 = np.arange(10)
a1
a1[2:5] = 2000
a1s = a1[2:5]
a1s
a1
a1s[1]=10
a1s
a1
a1s[:] = 3076
a1s
a1
a3d = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 13]]])
a3d
a3d[1]
a3d[0][1][2]
a3d[0, 1, 2]
a3d[0] = 5
a3d
a2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
a2d
a2d[:2]
a2d[:2, 1:]
a = np.arange(18).reshape(3, 6)
a
a.T
a.swapaxes(0, 1)
np.dot(a.T, a)
a.T @ a
a = np.arange(5)
a
np.sqrt(a)
np.exp(a)
b = np.arange(4, -1, -1)
b
np.maximum(a, b)
c = a / 3
c
i, r =np.modf(c)
i
r
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
a = np.arange(10) + 100
a
plt.plot(a)
fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)
ax1
ax2 = fig.add_subplot(2, 2, 2)
ax2
fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)
ax3.plot(np.random.standard_normal(50).cumsum(), color = "black", linestyle = "dashed")
fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)
ax3.plot(np.random.standard_normal(50).cumsum(), color = "black", linestyle = "dashed")
ax2.scatter(np.arange(30), np.arange(30) + 3 * np.random.standard_normal(30))
ax1.hist(np.random.standard_normal(100), bins = 20, color = "black", alpha = 0.3)
fig, axes = plt.subplots(2, 3)
axes
fig, axes = plt.subplots(2, 2, sharex = True, sharey= True)
for i in range(2):
for j in range(2):
axes[i, j].hist(np.random.standard_normal(500), bins = 50, color = "black", alpha = 0.5)
fig.subplots_adjust(wspace = 0, hspace = 0)