資料採礦與大數據分析實務-資料型態(一維)

資料採礦與大數據分析實務-資料型態(一維)

Error_0x03F7 作者

程式碼解釋筆記

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# D11016*** ***

## D11016*** ***

### D11016*** ***



# D11016*** ***

4+10



# 01_畫圖
import matplotlib.pyplot as plt # pip install matplotlib
import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)

fig, ax = plt.subplots()

# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

ax.barh(y_pos, performance, xerr=error, align='center')
ax.set_yticks(y_pos, labels=people)
ax.invert_yaxis() # labels read top-to-bottom
ax.set_xlabel('Performance')
ax.set_title('How fast do you want to go today?')

plt.show()



import matplotlib.pyplot as plt
import numpy as np

from matplotlib.patches import PathPatch
from matplotlib.path import Path

N = 400
t = np.linspace(0, 2 * np.pi, N)
r = 0.5 + np.cos(t)
x, y = r * np.cos(t), r * np.sin(t)

fig, ax = plt.subplots()
ax.plot(x, y, "k")
ax.set(aspect=1)

def draw_error_band(ax, x, y, err, **kwargs):
# Calculate normals via centered finite differences (except the first point
# which uses a forward difference and the last point which uses a backward
# difference).
dx = np.concatenate([[x[1] - x[0]], x[2:] - x[:-2], [x[-1] - x[-2]]])
dy = np.concatenate([[y[1] - y[0]], y[2:] - y[:-2], [y[-1] - y[-2]]])
l = np.hypot(dx, dy)
nx = dy / l
ny = -dx / l

# end points of errors
xp = x + nx * err
yp = y + ny * err
xn = x - nx * err
yn = y - ny * err

vertices = np.block([[xp, xn[::-1]],
[yp, yn[::-1]]]).T
codes = np.full(len(vertices), Path.LINETO)
codes[0] = codes[len(xp)] = Path.MOVETO
path = Path(vertices, codes)
ax.add_patch(PathPatch(path, **kwargs))


_, axs = plt.subplots(1, 2, layout='constrained', sharex=True, sharey=True)
errs = [
(axs[0], "constant error", 0.05),
(axs[1], "variable error", 0.05 * np.sin(2 * t) ** 2 + 0.04),
]
for i, (ax, title, err) in enumerate(errs):
ax.set(title=title, aspect=1, xticks=[], yticks=[])
ax.plot(x, y, "k")
draw_error_band(ax, x, y, err=err,
facecolor=f"C{i}", edgecolor="none", alpha=.3)

plt.show()



# 02_資料型態 type()
# 02_1_布林 bool

x1 = False

type(x1)



# 02_2_整數 int

x2 = 3
type(x2)



# 02_3_浮點數 float

x3 = 3.3
type(x3)



# 02_4_字串 str

x4 = "名字"
type(x4)



# 03_sep + end
print(1, 2, 3, 4)




# " " 、 ' ' 或 ''' ''' 都是字串
# 程式加條件 ,

print(1, 2, 3, 4, end= "|", sep= '|')



print(1, 2, 3, 4, end= "|")



# 04_input + if + for in + 讀取相片
# 04_1 input

print("將華氏轉成攝氏溫度")

f = float(input("請輸入華氏溫度"))

c = (f-32)*(5/9)

print("攝氏溫度為:" , c)

Jupyter 實作檔案

資料採礦與大數據分析實務-資料型態(一維)
  • 本文標題: 資料採礦與大數據分析實務-資料型態(一維)
  • 本文作者: Error_0x03F7
  • 撰寫於 : 2024-03-07 13:29:44
  • 更新於 : 2024-03-07 13:46:51
  • 本文連結: https://error0x03f7.vercel.app/2024/03/07/資料採礦與大數據分析實務-資料型態(一維)/
  • 版權聲明: 本文採用 CC BY-NC-SA 4.0 TW 進行許可。轉載請註明來自 Error_0x03F7 個人網站
留言
此頁目錄
資料採礦與大數據分析實務-資料型態(一維)