当前位置:网站首页>6.23星期四库作业
6.23星期四库作业
2022-07-03 05:16:00 【隹隹隹隹隹】
6.23星期四库作业
文章目录
Numpy实践
练习一:创建从0到9的一维数字数组
import numpy as np
arr = np.arange(10)
print(arr)

练习二:创建一个元素全为True的 3×3 数组
import numpy as np
arr = np.full([3, 3], True, dtype=np.bool)
print(arr)

练习三:创建一个二维数组,其中边界值为1,其余值为0
import numpy as np
Z = np.ones((10,10))
Z[1:-1,1:-1] = 0
print(Z)

Pandas实践
练习一:利用列表推导式写矩阵乘法
一般的矩阵乘法根据公式,可以由三重循环写出,请将其改写为列表推导式的形式。
M1 = np.random.rand(2,3)
M2 = np.random.rand(3,4)
res = np.empty((M1.shape[0],M2.shape[1]))
for i in range(M1.shape[0]):
for j in range(M2.shape[1]):
item = 0
for k in range(M1.shape[1]):
item += M1[i][k] * M2[k][j]
res[i][j] = item
(np.abs(([email protected] - res) < 1e-15)).all() # 排除数值误差
列表推导式的形式
import numpy as np
M1 = np.random.rand(2,3)
M2 = np.random.rand(3,4)
res = [[sum([M1[i][k] * M2[k][j] for k in range(M1.shape[1])]) for j in range(M2.shape[1])] for i in range(M1.shape[0])]
(np.abs(([email protected] - res) < 1e-15)).all()

Matplotlib实践
练习一: 两种绘图接口
matplotlib提供了两种最常用的绘图接口
- 显式创建figure和axes,在上面调用绘图方法,也被称为OO模式(object-oriented style)
- 依赖pyplot自动创建figure和axes,并绘图
使用第一种绘图接口,是这样的:
x = np.linspace(0, 2, 100)
fig, ax = plt.subplots()
ax.plot(x, x, label='linear')
ax.plot(x, x**2, label='quadratic')
ax.plot(x, x**3, label='cubic')
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax.set_title("Simple Plot")
ax.legend()

第二种绘图接口
x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')
plt.plot(x, x**2, label='quadratic')
plt.plot(x, x**3, label='cubic')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title("Simple Plot")
plt.legend()

边栏推荐
- [basic grammar] Snake game written in C language
- Redis 击穿穿透雪崩
- 2022-02-12 daily clock in: problem fine brush
- [backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times
- Use posture of sudo right raising vulnerability in actual combat (cve-2021-3156)
- Wechat applet distance and map
- [basic grammar] C language uses for loop to print Pentagram
- JS string and array methods
- 音频焦点系列:手写一个demo理解音频焦点与AudioMananger
- Congratulations to musk and NADELLA on their election as academicians of the American Academy of engineering, and Zhang Hongjiang and Fang daining on their election as foreign academicians
猜你喜欢
![[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached](/img/01/052928e7f20ca671cdc4c30ae55258.jpg)
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
![[practical project] autonomous web server](/img/99/892e600b7203c63bad02adb683c8f2.png)
[practical project] autonomous web server

es7创建索引容易犯的错误

Go practice -- design patterns in golang's singleton

Yolov5 network structure + code + application details | CSDN creation punch in

酒店公共广播背景音乐-基于互联网+的酒店IP网络广播系统设计
![[basic grammar] Snake game written in C language](/img/cb/83631ef3ccd7047ca42d33dc49bf90.jpg)
[basic grammar] Snake game written in C language

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis

(完美解决)matplotlib图例(legend)如何自由设置其位置

BIO、NIO、AIO区别
随机推荐
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
Online VR model display - 3D visual display solution
Shallow and first code
C language program ideas and several commonly used filters
Three representations of signed numbers: original code, inverse code and complement code
Go practice -- factory mode of design patterns in golang (simple factory, factory method, abstract factory)
BIO、NIO、AIO区别
JS dynamic table creation
1114 family property (25 points)
Rust基础入门之(基本类型)
Notes | numpy-07 Slice and index
Notes | numpy-08 Advanced index
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
Webrtc M96 release notes (SDP abolishes Plan B and supports opus red redundant coding)
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
(subplots usage) Matplotlib how to draw multiple subgraphs (axis field)
1099 build a binary search tree (30 points)
Go practice -- generate and read QR codes in golang (skip2 / go QRcode and boombuilder / barcode)
Handler understands the record
appium1.22.x 版本後的 appium inspector 需單獨安裝