Skip to content

Commit c249981

Browse files
committed
commit
1 parent 12574ca commit c249981

File tree

2 files changed

+92
-36
lines changed

2 files changed

+92
-36
lines changed

.idea/workspace.xml

Lines changed: 40 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python基础代码/科学计算基础学习/Nmupy基础练习.py

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,60 @@
192192

193193

194194
""""数组的类型转换"""
195-
# 数组转换成list,使用tolist()
196-
b = np.arange(12).reshape(2, 6)
197-
print(b.tolist())
198-
print(type(b.tolist()))
199-
# 不会改变原来的numpy数组
195+
# 数组转换成list,使用tolist() 不会改变原来的numpy数组
196+
# b = np.arange(12).reshape(2, 6)
197+
# print(b.tolist())
198+
# print(type(b.tolist()))
200199

200+
# 转换成指定类型,astype()函数
201+
# print(b.astype(float))
201202

202-
'''一些简单练习'''
203+
204+
205+
"""numpy常用统计函数"""
206+
# 请注意函数在使用时需要指定axis轴的方向,若不指定,默认统计整个数组。
207+
208+
# np.sum(),返回求和
209+
# np.mean(),返回均值
210+
211+
# np.max(),返回最大值
212+
# print(np.max(b))
213+
# 沿axis=1轴方向统计
214+
# np.max(b,axis=1)
215+
# 沿axis=0轴方向统计
216+
# np.max(b,axis=0)
217+
218+
# np.min(),返回最小值
219+
# print(np.min(b))
220+
221+
# np.ptp(),数组沿指定轴返回最大值减去最小值,即(max-min)
222+
# print(np.ptp(b))
223+
224+
# np.std(),返回标准偏差(standard deviation)
225+
# np.var(),返回方差(variance)
226+
227+
# np.cumsum(),返回累加值
228+
# print(np.cumsum(b, axis=1))
229+
230+
# np.cumprod(),返回累乘积值
231+
# print(np.cumprod(b,axis=1))
232+
# print(np.cumprod(b,axis=0))
233+
234+
235+
236+
"""数组的广播"""
237+
# 当数组跟一个标量进行数学运算时,标量需要根据数组的形状进行扩展,然后执行运算。
238+
# 这个扩展的过程称为“广播(broadcasting)”
239+
240+
# b = np.arange(12).reshape(2, 6)
241+
# d = b + 2
242+
# print(d)
243+
244+
245+
246+
247+
248+
""""一些简单练习"""
203249

204250
# weight = [65.4, 59.2, 63.6, 88.4, 68.7] #体重列表
205251
# height = [1.73, 1.68, 1.71, 1.89, 1.79] #身高列表

0 commit comments

Comments
 (0)