组队学习资料
This commit is contained in:
@@ -180,6 +180,75 @@
|
||||
"# [5 6 7 8 9 1 1 1 1 1]]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**将 `arr`的2维数组按列输出。**\n",
|
||||
"- `arr = np.array([[16, 17, 18, 19, 20],[11, 12, 13, 14, 15],[21, 22, 23, 24, 25],[31, 32, 33, 34, 35],[26, 27, 28, 29, 30]])`\n",
|
||||
"\n",
|
||||
"【知识点:数组的操作】\n",
|
||||
"- 如何访问二维数组的全部元素,并按列输出?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[16 11 21 31 26 17 12 22 32 27 18 13 23 33 28 19 14 24 34 29 20 15 25 35\n",
|
||||
" 30]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"arr = np.array([[16, 17, 18, 19, 20],[11, 12, 13, 14, 15],[21, 22, 23, 24, 25],[31, 32, 33, 34, 35],[26, 27, 28, 29, 30]])\n",
|
||||
"y = arr.flatten(order='F')\n",
|
||||
"print(y)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**给定两个随机数组A和B,验证它们是否相等。**\n",
|
||||
"\n",
|
||||
"- `A = np.random.randint(0,2,5) B = np.random.randint(0,2,5)`"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"True\n",
|
||||
"True\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"A = np.array([1,2,3])\n",
|
||||
"B = np.array([1,2,3])\n",
|
||||
"\n",
|
||||
"# Assuming identical shape of the arrays and a tolerance for the comparison of values\n",
|
||||
"equal = np.allclose(A,B)\n",
|
||||
"print(equal)\n",
|
||||
"\n",
|
||||
"# Checking both the shape and the element values, no tolerance (values have to be exactly equal)\n",
|
||||
"equal = np.array_equal(A,B)\n",
|
||||
"print(equal)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
@@ -235,6 +304,41 @@
|
||||
"metadata": {},
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**建立一个随机数在1-10之间的3行2列的数组,并将其转换成2行3列的数组。**\n",
|
||||
"\n",
|
||||
"【知识点:数组的操作】\n",
|
||||
"- 改变数组形状?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[9 0]\n",
|
||||
" [3 3]\n",
|
||||
" [4 6]]\n",
|
||||
"[[9 0 3]\n",
|
||||
" [3 4 6]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"x = np.random.randint(10, size=[3, 2])\n",
|
||||
"print(x)\n",
|
||||
"y = np.reshape(x, [2,3])\n",
|
||||
"print(y)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -245,9 +349,9 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python35",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python35"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **8. 将数组a与数组b水平堆叠。**\n",
|
||||
"### 将数组a与数组b水平堆叠。\n",
|
||||
"- `a = np.arange(10).reshape([2, -1])`\n",
|
||||
"- `b = np.repeat(1, 10).reshape([2, -1])`\n",
|
||||
"\n",
|
||||
@@ -35,6 +35,30 @@
|
||||
"- 如何水平叠加两个数组?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **将 `arr`的2维数组按列输出。**\n",
|
||||
"\n",
|
||||
"- `arr = np.array([[16, 17, 18, 19, 20],[11, 12, 13, 14, 15],[21, 22, 23, 24, 25],[31, 32, 33, 34, 35],[26, 27, 28, 29, 30]])`\n",
|
||||
"\n",
|
||||
"【知识点:数组的操作】\n",
|
||||
"- 如何访问二维数组的全部元素,并按列输出?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **给定两个随机数组A和B,验证它们是否相等。**\n",
|
||||
"\n",
|
||||
"- `A = np.random.randint(0,2,5) B = np.random.randint(0,2,5)`\n",
|
||||
"\n",
|
||||
"【知识点:数组的操作】\n",
|
||||
"- np.allclose()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -46,20 +70,13 @@
|
||||
"【知识点:数组操作】\n",
|
||||
"- 如何在numpy数组中找到重复值?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python35",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python35"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
@@ -84,7 +101,7 @@
|
||||
"toc_cell": false,
|
||||
"toc_position": {},
|
||||
"toc_section_display": true,
|
||||
"toc_window_display": false
|
||||
"toc_window_display": true
|
||||
},
|
||||
"varInspector": {
|
||||
"cols": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -100,6 +100,34 @@
|
||||
"则P到直线的距离为:d=|Ax0+By0+C|/√(A²+B²)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **画正弦函数和余弦函数, x = np.arange(0, 3 * np.pi, 0.1)?**\n",
|
||||
"【知识点:数学函数】"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **减去矩阵每一行的平均值 ?**\n",
|
||||
"【知识点:数学函数】\n",
|
||||
"- 提示: mean(axis=,keepdims=)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **进行概率统计分析 ?**\n",
|
||||
"- `arr1 = np.random.randint(1,10,10)\n",
|
||||
"arr2 = np.random.randint(1,10,10))\n",
|
||||
"【知识点:数学函数】 \n",
|
||||
"平均数,中位数,方差,标准差,相关性矩阵,协方差矩阵等`\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -153,6 +181,16 @@
|
||||
"- (提示: np.logical_not, np.negative)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **找出数组中与给定值最接近的数**\n",
|
||||
"\n",
|
||||
"【知识点:逻辑函数】\n",
|
||||
"- (提示: np.abs().argmin())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -163,9 +201,9 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python35",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python35"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
|
||||
Reference in New Issue
Block a user