{"id":111019,"date":"2026-09-30T06:24:43","date_gmt":"2026-09-29T22:24:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/111019.html"},"modified":"2026-09-30T06:24:43","modified_gmt":"2026-09-29T22:24:43","slug":"%e6%9c%ba%e5%99%a8%e5%ad%a6%e4%b9%a0%e4%b9%8bnumpy%ef%bc%88machine-learning-about-numpy%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/111019.html","title":{"rendered":"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09"},"content":{"rendered":"<h2>\u4e8c\u3001NumPy\u6570\u636e\u5904\u7406<\/h2>\n<h3>1\u3001Numpy\u57fa\u7840\u4e0e\u6570\u7ec4\u521b\u5efa<\/h3>\n<h4>1.1 Numpy\u57fa\u7840\u77e5\u8bc6<\/h4>\n<p>Numpy&#xff08;Numerical Python&#xff09;\u662fPython\u7f16\u7a0b\u8bed\u8a00\u91cc\u9762\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\u7684\u57fa\u7840\u5e93&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61 narray \u4ee5\u53ca\u4e00\u7cfb\u5217\u7528\u4e8e\u64cd\u4f5c\u8fd9\u7c7b\u6570\u7ec4\u7684\u5de5\u5177\u51fd\u6570\u3002NumPy\u4e8e2005\u5e74\u53d1\u5e03&#xff0c;\u73b0\u5982\u4eca\u5df2\u6210\u4e3aPython\u6570\u636e\u79d1\u5b66\u751f\u6001\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u4ef6\u3002<\/p>\n<p>&#x1f4a1;<span style=\"color:#444444\">\u91cd\u8981\u63d0\u793a<\/span><span style=\"color:#444444\">&#xff1a;<\/span><span style=\"color:#444444\">pandas<\/span><span style=\"color:#444444\">\u3001<\/span><span style=\"color:#444444\">scipy<\/span><span style=\"color:#444444\">\u3001<\/span><span style=\"color:#444444\">scikit-learn<\/span><span style=\"color:#444444\">\u7b49\u4e3b\u6d41\u6570\u636e\u5904\u7406\u5e93\u90fd\u662f\u57fa\u4e8e<\/span><span style=\"color:#444444\">NumPy<\/span><span style=\"color:#444444\">\u6784\u5efa\u7684\u3002\u638c\u63e1<\/span><span style=\"color:#444444\">NumPy<\/span><span style=\"color:#444444\">\u5c31<\/span><span style=\"color:#444444\">\u50cf\u638c\u63e1\u4e86\u6570\u636e\u5206\u6790\u7684\u300c\u5185\u529f\u5fc3\u6cd5\u300d&#xff0c;\u540e\u7eed\u5b66\u4e60\u5176\u4ed6\u5e93\u5c06\u4e8b\u534a\u529f\u500d\u3002<\/span><\/p>\n<p>NumPy\u7684\u6838\u5fc3\u7279\u6027\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\u5411\u91cf\u5316\u8fd0\u7b97&#xff1a;\u65e0\u9700\u7f16\u5199\u5faa\u73af\u5373\u53ef\u5bf9\u6574\u4e2a\u6570\u7ec4\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\u3002<\/li>\n<li>\u5e7f\u64ad\u673a\u5236&#xff1a;\u652f\u6301\u4e0d\u540c\u5f62\u72b6\u6570\u7ec4\u4e4b\u95f4\u7684\u8fd0\u7b97\u3002<\/li>\n<li>\u9ad8\u6548\u5185\u5b58\u5b58\u50a8&#xff1a;\u8fde\u7eed\u5185\u5b58\u5757\u5b58\u50a8&#xff0c;\u8bbf\u95ee\u901f\u5ea6\u5feb\u3002<\/li>\n<li>\u4e30\u5bcc\u7684\u6570\u5b66\u51fd\u6570\u5e93&#xff1a;\u7ebf\u6027\u4ee3\u6570\u3001\u5085\u91cc\u53f6\u53d8\u6362\u3001\u968f\u673a\u6570\u751f\u6210\u7b49\u3002<\/li>\n<\/ul>\n<h4>1.2 ndarray \u4e0e Python\u5217\u8868<\/h4>\n<p>\u5bf9\u4e8ePython\u5217\u8868\u4e0eNumpy\u6570\u7ec4\u4e24\u8005\u4e4b\u95f4\u7684\u5173\u7cfb\u8ba9\u5927\u591a\u6570\u521d\u5b66\u8005\u6709\u4e9b\u4e0d\u89e3&#xff0c;\u867d\u7136\u770b\u7740\u5e76\u65e0\u5dee\u522b&#xff0c;\u4f46\u662f\u901a\u8fc7\u7279\u6027\u56de\u6765\u770b\u786e\u5b9e\u5927\u4e0d\u76f8\u540c\u3002<\/p>\n<p>&#x1f4a1;NumPy\u6570\u7ec4<\/p>\n<ul>\n<li>\u5143\u7d20\u7c7b\u578b&#xff1a;\u5fc5\u987b\u540c\u8d28<\/li>\n<li>\u8fd0\u7b97\u65b9\u5f0f&#xff1a;\u5411\u91cf\u5316\u8fd0\u7b97<\/li>\n<li>\u6267\u884c\u901f\u5ea6&#xff1a;\u4f7f\u7528C\u8bed\u8a00\u4f5c\u4e3a\u5e95\u5c42&#xff0c;\u901f\u5ea6\u5feb<\/li>\n<li>\u5185\u5b58\u5360\u7528&#xff1a;\u7d27\u51d1&#xff0c;\u8fde\u7eed\u5185\u5b58\u5757<\/li>\n<li>\u7ef4\u5ea6\u652f\u6301&#xff1a;\u539f\u751fN\u7ef4\u6570\u7ec4<\/li>\n<li>\u529f\u80fd\u4e30\u5bcc\u5ea6&#xff1a;\u591a\u7ef4\u8fd0\u7b97\u3001\u77e9\u9635\u5206\u89e3\u3001\u7edf\u8ba1\u805a\u5408<\/li>\n<\/ul>\n<p>import numpy as np<br \/>\nimport time<\/p>\n<p># Python\u5217\u8868&#xff1a;\u5faa\u73af\u6c42\u548c<br \/>\npy_list &#061; list(range(1000000))<br \/>\nstart &#061; time.time()<br \/>\npy_sum &#061; sum(py_list)<br \/>\nprint(f&#034;Python\u5217\u8868\u6c42\u548c\u8017\u65f6&#xff1a;{time.time() &#8211; start:.4f}\u79d2&#034;)<\/p>\n<p># NumPy\u6570\u7ec4&#xff1a;\u5411\u91cf\u5316\u6c42\u548c<br \/>\nnp_arr &#061; np.arange(1000000)<br \/>\nstart &#061; time.time()<br \/>\nnp_sum &#061; np_arr.sum()<br \/>\nprint(f&#034;NumPy\u6570\u7ec4\u6c42\u548c\u8017\u65f6&#xff1a;{time.time() &#8211; start:.4f}\u79d2&#034;)<\/p>\n<h4>1.3 \u521b\u5efa\u6570\u7ec4\u7684\u65b9\u5f0f<\/h4>\n<p># NumPy\u5e93<br \/>\nimport numpy as np<\/p>\n<p># \u65b9\u5f0f1&#xff1a;\u4ecePython\u5217\u8868\u8f6c\u6362&#xff08;\u6700\u5e38\u7528&#xff09;<br \/>\na &#061; np.array([1, 2, 3, 4, 5])<br \/>\nprint(f&#034;\u4ece\u5217\u8868\u521b\u5efa&#xff1a;{a}&#034;) # [1 2 3 4 5]<\/p>\n<p># \u65b9\u5f0f2&#xff1a;\u51680\u6570\u7ec4<br \/>\nzeros_1d &#061; np.zeros(5) # \u4e00\u7ef4&#xff1a;5\u4e2a\u5143\u7d20<br \/>\nzeros_2d &#061; np.zeros((3, 4)) # \u4e8c\u7ef4&#xff1a;3\u884c4\u5217<br \/>\nprint(f&#034;\u51680\u4e00\u7ef4\u6570\u7ec4&#xff1a;{zeros_1d}&#034;)<br \/>\n# [0. 0. 0. 0. 0.]<\/p>\n<p># \u65b9\u5f0f3&#xff1a;\u51681\u6570\u7ec4<br \/>\nones_1d &#061; np.ones(5)<br \/>\nones_2d &#061; np.ones((3, 4))<br \/>\nprint(f&#034;\u51681\u4e8c\u7ef4\u6570\u7ec4&#xff1a;\\\\n{ones_2d}&#034;)<br \/>\n# [[1. 1. 1. 1.]<br \/>\n# [1. 1. 1. 1.]<br \/>\n# [1. 1. 1. 1.]]<\/p>\n<p># \u65b9\u5f0f4&#xff1a;\u6307\u5b9a\u586b\u5145\u503c\u7684\u6570\u7ec4<br \/>\nfull_arr &#061; np.full((2, 3), 7) # 2\u884c3\u5217&#xff0c;\u5168\u90e8\u586b\u51457<br \/>\nprint(f&#034;\u51687\u6570\u7ec4&#xff1a;\\\\n{full_arr}&#034;)<br \/>\n# [[7 7 7]<br \/>\n# [7 7 7]]<\/p>\n<p># \u65b9\u5f0f5&#xff1a;\u8303\u56f4\u6570\u7ec4<br \/>\narr1 &#061; np.arange(0, 10, 2) # \u5f00\u59cb0&#xff0c;\u7ed3\u675f10&#xff0c;\u6b65\u957f2<br \/>\narr2 &#061; np.linspace(0, 1, 5) # \u5f00\u59cb0&#xff0c;\u7ed3\u675f1&#xff0c;\u5747\u5300\u5207\u52065\u4efd<br \/>\nprint(f&#034;arange\u521b\u5efa&#xff1a;{arr1}&#034;) # [0 2 4 6 8]<br \/>\nprint(f&#034;linspace\u521b\u5efa&#xff1a;{arr2}&#034;) # [0. 0.25 0.5 0.75 1. ]<\/p>\n<p># \u65b9\u5f0f6&#xff1a;\u968f\u673a\u6570\u7ec4&#xff08;\u6700\u5e38\u7528&#xff09;<br \/>\nrand_uniform &#061; np.random.rand(3, 4) # 0~1\u5747\u5300\u5206\u5e03<br \/>\nrand_int &#061; np.random.randint(0, 10, (3, 4)) # 0~10\u6574\u6570\u968f\u673a<br \/>\nrandn &#061; np.random.randn(3, 4) # \u6807\u51c6\u6b63\u6001\u5206\u5e03&#xff08;\u5747\u503c0\u65b9\u5dee1&#xff09;<br \/>\nprint(f&#034;\u968f\u673a\u6574\u6570\u6570\u7ec4&#xff1a;\\\\n{rand_int}&#034;)<\/p>\n<p>&#x1f4a1;<span style=\"color:#444444\">\u6ce8\u610f\u4e8b\u9879<\/span><span style=\"color:#444444\">&#xff1a; <\/span><span style=\"color:#c7254e\">np.arange() <\/span><span style=\"color:#444444\">\u7684\u533a\u95f4\u662f\u5de6\u95ed\u53f3\u5f00 <\/span><span style=\"color:#c7254e\">[start, stop) <\/span><span style=\"color:#444444\">&#xff0c;\u800c <\/span><span style=\"color:#c7254e\">np.linspace() <\/span><span style=\"color:#444444\">\u662f\u5de6\u95ed\u53f3\u95ed <\/span><span style=\"color:#c7254e\">[st <\/span><\/p>\n<p><span style=\"color:#c7254e\">art, stop] <\/span><span style=\"color:#444444\">\u3002<\/span><\/p>\n<h4>1.4 \u6570\u7ec4\u7684\u5173\u952e\u5c5e\u6027<\/h4>\n<p>\u6bcf\u4e2aNumPy\u6570\u7ec4\u90fd\u6709\u4ee5\u4e0b\u91cd\u8981\u5c5e\u6027&#xff0c;\u7406\u89e3\u5b83\u4eec\u5bf9\u4e8e\u6570\u7ec4\u7684\u64cd\u4f5c\u53ef\u8c13\u662f\u5fc5\u4e0d\u53ef\u5c11&#xff1a;<\/p>\n<p>a &#061; np.array([[1, 2, 3], [4, 5, 6]])<\/p>\n<p>print(f&#034;\u5f62\u72b6 (shape)&#xff1a;{a.shape}&#034;) # (2, 3) &#8211; 2\u884c3\u5217<br \/>\nprint(f&#034;\u7ef4\u5ea6\u6570 (ndim)&#xff1a;{a.ndim}&#034;) # 2 &#8211; \u4e8c\u7ef4\u6570\u7ec4<br \/>\nprint(f&#034;\u6570\u636e\u7c7b\u578b (dtype)&#xff1a;{a.dtype}&#034;) # int64 &#8211; 64\u4f4d\u6574\u6570<br \/>\nprint(f&#034;\u5143\u7d20\u603b\u6570 (size)&#xff1a;{a.size}&#034;) # 6 &#8211; \u51716\u4e2a\u5143\u7d20<br \/>\nprint(f&#034;\u5355\u4e2a\u5143\u7d20\u5b57\u8282\u6570 (itemsize)&#xff1a;{a.itemsize}&#034;) # 8<br \/>\nprint(f&#034;\u6570\u7ec4\u603b\u5b57\u8282\u6570 (nbytes)&#xff1a;{a.nbytes}&#034;) # 48<\/p>\n<h4>1.5\u00a0 \u6570\u636e\u7c7b\u578b\u8be6\u89e3<\/h4>\n<p>NumPy\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b&#xff0c;\u5408\u7406\u9009\u62e9\u53ef\u4ee5\u8282\u7701\u5185\u5b58&#xff1a;<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td>dtype<\/td>\n<td>\u8bf4\u660e<\/td>\n<td>\u5b57\u8282\u6570<\/td>\n<td>\u5178\u578b\u7528\u9014<\/td>\n<\/tr>\n<tr>\n<td>int32<\/td>\n<td>32\u4f4d\u6574\u6570<\/td>\n<td>4<\/td>\n<td>\u4e00\u822c\u6574\u6570\u8fd0\u7b97<\/td>\n<\/tr>\n<tr>\n<td>int64<\/td>\n<td>64\u4f4d\u6574\u6570<\/td>\n<td>8<\/td>\n<td>\u5927\u6570\u503c\u7edf\u8ba1<\/td>\n<\/tr>\n<tr>\n<td>float32<\/td>\n<td>\u5355\u7cbe\u5ea6\u6d6e\u70b9<\/td>\n<td>4<\/td>\n<td>\u5185\u5b58\u654f\u611f\u573a\u666f<\/td>\n<\/tr>\n<tr>\n<td>float<\/td>\n<td>\u53cc\u7cbe\u5ea6\u6d6e\u70b9<\/td>\n<td>8<\/td>\n<td>\u7cbe\u5ea6\u8981\u6c42\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>bool<\/td>\n<td>\u5e03\u5c14\u7c7b\u578b<\/td>\n<td>1<\/td>\n<td>\u6761\u4ef6\u5224\u65ad<\/td>\n<\/tr>\n<tr>\n<td>boject<\/td>\n<td>Python\u5bf9\u8c61<\/td>\n<td>\u53ef\u53d8<\/td>\n<td>\u6df7\u5408\u7c7b\u578b\u5b58\u50a8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p># \u6307\u5b9a\u6570\u636e\u7c7b\u578b<br \/>\narr1 &#061; np.array([1, 2, 3], dtype&#061;np.float32)<br \/>\narr2 &#061; np.array([1, 2, 3], dtype&#061;np.float64)<br \/>\nprint(f&#034;float32\u5185\u5b58&#xff1a;{arr1.nbytes}\u5b57\u8282&#034;) # 12<br \/>\nprint(f&#034;float64\u5185\u5b58&#xff1a;{arr2.nbytes}\u5b57\u8282&#034;) # 24<\/p>\n<hr \/>\n<h3>2\u3001\u6570\u7ec4\u7d22\u5f15\u4e0e\u5207\u7247<\/h3>\n<h4>2.1 \u4e00\u7ef4\u6570\u7ec4\u7d22\u5f15\u57fa\u7840<\/h4>\n<p>NumPy\u6570\u7ec4\u7684\u7d22\u5f15\u65b9\u5f0f\u4e0e Python \u5217\u8868\u7c7b\u4f3c&#xff0c;\u4f46\u529f\u80fd\u5f3a\u5927\u3002\u7d22\u5f15\u57fa\u7840\u89c4\u5219&#xff1a;<\/p>\n<ul>\n<li>\u6b63\u5411\u7d22\u5f15&#xff1a;\u4ece0\u5f00\u59cb&#xff0c;a[0] \u662f\u7b2c\u4e00\u4e2a\u5143\u7d20<\/li>\n<li>\u8d1f\u5411\u7d22\u5f15&#xff1a;\u4ece-1\u5f00\u59cb&#xff0c;a[-1] \u662f\u6700\u540e\u4e00\u4e2a\u5143\u7d20<\/li>\n<li>\u5207\u7247&#xff1a;a[start:stop:step]&#xff0c;\u9075\u5faa\u5de6\u95ed\u53f3\u5f00\u539f\u5219<\/li>\n<\/ul>\n<p>a &#061; np.arange(10) # \u521b\u5efa [0 1 2 3 4 5 6 7 8 9]<br \/>\nprint(f&#034;\u539f\u6570\u7ec4&#xff1a;{a}&#034;)<\/p>\n<p># \u6b63\u5411\u7d22\u5f15<br \/>\nprint(f&#034;a[0] &#061; {a[0]}&#034;) # 0<br \/>\nprint(f&#034;a[5] &#061; {a[5]}&#034;) # 5<\/p>\n<p># \u8d1f\u5411\u7d22\u5f15<br \/>\nprint(f&#034;a[-1] &#061; {a[-1]}&#034;) # 9<br \/>\nprint(f&#034;a[-3] &#061; {a[-3]}&#034;) # 7<\/p>\n<p># \u5207\u7247\u64cd\u4f5c<br \/>\nprint(f&#034;a[2:7] &#061; {a[2:7]}&#034;) # [2 3 4 5 6] &#8211; \u7b2c3\u5230\u7b2c7\u4e2a\u5143\u7d20<br \/>\nprint(f&#034;a[:5] &#061; {a[:5]}&#034;) # [0 1 2 3 4] &#8211; \u4ece\u5934\u5230\u7b2c5\u4e2a<br \/>\nprint(f&#034;a[5:] &#061; {a[5:]}&#034;) # [5 6 7 8 9] &#8211; \u4ece\u7b2c6\u4e2a\u5230\u672b\u5c3e<\/p>\n<p># \u6b65\u957f\u5207\u7247<br \/>\nprint(f&#034;a[::2] &#061; {a[::2]}&#034;) # [0 2 4 6 8] &#8211; \u6b65\u957f2<br \/>\nprint(f&#034;a[::3] &#061; {a[::3]}&#034;) # [0 3 6 9] &#8211; \u6b65\u957f3<br \/>\nprint(f&#034;a[::-1] &#061; {a[::-1]}&#034;) # [9 8 7 6 5 4 3 2 1 0] &#8211; \u5b8c\u5168\u53cd\u8f6c<\/p>\n<h4>2.2 \u4e8c\u7ef4\u6570\u7ec4\u7d22\u5f15<\/h4>\n<p>\u4e8c\u7ef4\u6570\u7ec4\u7684\u7d22\u5f15\u9700\u8981\u540c\u65f6\u6307\u5b9a\u884c\u548c\u5217&#xff0c;\u8bed\u6cd5\u4e3a array[row, col]&#xff1a;<\/p>\n<p>b &#061; np.array([<br \/>\n    [1, 2, 3],<br \/>\n    [4, 5, 6],<br \/>\n    [7, 8, 9]<br \/>\n])<br \/>\nprint(f&#034;\u539f\u6570\u7ec4&#xff1a;\\\\n{b}&#034;)<\/p>\n<p># \u5355\u4e2a\u5143\u7d20\u7d22\u5f15<br \/>\nprint(f&#034;b[1, 2] &#061; {b[1, 2]}&#034;) # 6 &#8211; \u7b2c2\u884c\u7b2c3\u5217<\/p>\n<p># \u884c\u7d22\u5f15<br \/>\nprint(f&#034;b[0, :] &#061; {b[0, :]}&#034;) # [1 2 3] &#8211; \u7b2c1\u884c\u6240\u6709\u5217<br \/>\nprint(f&#034;b[1] &#061; {b[1]}&#034;) # [4 5 6] &#8211; \u7b2c2\u884c&#xff08;\u7701\u7565\u5199\u6cd5&#xff09;<\/p>\n<p># \u5217\u7d22\u5f15<br \/>\nprint(f&#034;b[:, 1] &#061; {b[:, 1]}&#034;) # [2 5 8] &#8211; \u7b2c2\u5217\u6240\u6709\u884c<\/p>\n<p># \u5b50\u77e9\u9635\u5207\u7247<br \/>\nprint(f&#034;b[0:2, 0:2] &#061; \\\\n{b[0:2, 0:2]}&#034;)<br \/>\n# [[1 2]<br \/>\n# [4 5]]<\/p>\n<p># \u8df3\u884c\u8df3\u5217<br \/>\nprint(f&#034;b[::2, ::2] &#061; \\\\n{b[::2, ::2]}&#034;)<br \/>\n# [[1 3]<br \/>\n# [7 9]]<\/p>\n<h4>2.3 \u5e03\u5c14\u7d22\u5f15<\/h4>\n<p>\u5e03\u5c14\u7d22\u5f15\u662f NumPy \u91cc\u9762\u6700\u5f3a\u5927\u7684\u7279\u5f81\u4e4b\u4e00&#xff0c;\u5b83\u5141\u8bb8\u6211\u4eec\u6839\u636e\u6761\u4ef6\u7b5b\u9009\u6570\u7ec4\u5143\u7d20&#xff1a;<\/p>\n<p>a &#061; np.array([10, 20, 30, 40, 50])<br \/>\nprint(f&#034;\u539f\u6570\u7ec4&#xff1a;{a}&#034;)<\/p>\n<p># \u521b\u5efa\u5e03\u5c14\u63a9\u7801<br \/>\nmask &#061; a &gt; 30<br \/>\nprint(f&#034;a &gt; 30 \u7684\u63a9\u7801&#xff1a;{mask}&#034;) # [False False False True True]<\/p>\n<p># \u4f7f\u7528\u63a9\u7801\u7b5b\u9009<br \/>\nresult &#061; a[mask]<br \/>\nprint(f&#034;a[a &gt; 30] &#061; {result}&#034;) # [40 50]<\/p>\n<p># \u4e00\u884c\u5199\u6cd5&#xff08;\u6700\u5e38\u7528&#xff09;<br \/>\nprint(f&#034;a[a &gt; 25] &#061; {a[a &gt; 25]}&#034;) # [30 40 50]<\/p>\n<p>&#x1f4a1;<span style=\"color:#444444\">\u6838\u5fc3\u5e94\u7528\u573a\u666f<\/span><span style=\"color:#444444\">&#xff1a;\u5728\u6570\u636e\u5206\u6790\u4e2d&#xff0c;\u5e03\u5c14\u7d22\u5f15\u7528\u4e8e\u6570\u636e\u6e05\u6d17\u3001\u5f02\u5e38\u503c\u68c0\u6d4b\u3001\u6761\u4ef6\u7b5b\u9009\u7b49\u573a\u666f\u3002<\/span><\/p>\n<p>\u5b9e\u9645\u5e94\u7528&#xff1a;<\/p>\n<p># \u573a\u666f&#xff1a;\u7b5b\u9009\u4ef7\u683c\u5927\u4e8e150\u7684\u5546\u54c1<br \/>\nprices &#061; np.array([99, 199, 299, 399, 149])<br \/>\nprint(f&#034;\u9ad8\u4ef7\u5546\u54c1\u4ef7\u683c&#xff1a;{prices[prices &gt; 150]}&#034;) # [199 299 399]<\/p>\n<p># \u573a\u666f&#xff1a;\u7b5b\u9009\u6210\u7ee9\u53ca\u683c\u7684\u5b66\u751f<br \/>\nscores &#061; np.array([45, 78, 92, 63, 88, 55, 76])<br \/>\nprint(f&#034;\u53ca\u683c\u6210\u7ee9&#xff1a;{scores[scores &gt;&#061; 60]}&#034;) # [78 92 63 88 76]<\/p>\n<p># \u590d\u5408\u6761\u4ef6<br \/>\na &#061; np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])<\/p>\n<p># \u627e\u51fa\u5927\u4e8e3\u4e14\u5c0f\u4e8e8\u7684\u6570<br \/>\nresult &#061; a[(a &gt; 3) &amp; (a &lt; 8)]<br \/>\nprint(f&#034;\u5927\u4e8e3\u4e14\u5c0f\u4e8e8&#xff1a;{result}&#034;) # [4 5 6 7]<\/p>\n<p>&#x1f4a1;<span style=\"color:#444444\">\u6ce8\u610f<\/span><span style=\"color:#444444\">&#xff1a;\u5728<\/span><span style=\"color:#444444\">NumPy<\/span><span style=\"color:#444444\">\u4e2d\u8fdb\u884c\u590d\u5408\u6761\u4ef6\u7b5b\u9009\u65f6&#xff0c;\u5fc5\u987b\u4f7f\u7528 <\/span><span style=\"color:#c7254e\">&amp; <\/span><span style=\"color:#444444\">&#xff08;\u6309\u4f4d\u4e0e&#xff09;\u800c\u4e0d\u662f <\/span><span style=\"color:#c7254e\">and <\/span><span style=\"color:#444444\">&#xff08;<\/span><span style=\"color:#444444\">Python<\/span><span style=\"color:#444444\">\u903b\u8f91\u4e0e&#xff09;&#xff0c;<\/span><span style=\"color:#444444\">\u56e0\u4e3a<\/span><span style=\"color:#444444\">NumPy<\/span><span style=\"color:#444444\">\u64cd\u4f5c\u7684\u662f\u6570\u7ec4\u800c\u4e0d\u662f\u5355\u4e2a\u503c\u3002<\/span><\/p>\n<h4>2.4 \u82b1\u5f0f\u7d22\u5f15<\/h4>\n<p>\u82b1\u5f0f\u7d22\u5f15&#xff08;Fancy Indexing&#xff09;\u4f7f\u7528\u6574\u6570\u6570\u7ec4\u4f5c\u4e3a\u7d22\u5f15&#xff0c;\u53ef\u4ee5\u5b9e\u73b0\u4efb\u610f\u987a\u5e8f\u3001\u4efb\u610f\u4f4d\u7f6e\u7684\u5143\u7d20\u9009\u53d6&#xff1a;<\/p>\n<p>a &#061; np.arange(10) # [0 1 2 3 4 5 6 7 8 9]<\/p>\n<p># \u4f7f\u7528\u6574\u6570\u6570\u7ec4\u6307\u5b9a\u7d22\u5f15\u4f4d\u7f6e<br \/>\nindices &#061; [0, 2, 4, 6]<br \/>\nprint(f&#034;a[{indices}] &#061; {a[indices]}&#034;) # [0 2 4 6]<\/p>\n<p># \u4e0d\u6309\u987a\u5e8f\u9009\u53d6<br \/>\nprint(f&#034;a[[3, 0, 5]] &#061; {a[[3, 0, 5]]}&#034;) # [3 0 5]<\/p>\n<p># \u4e8c\u7ef4\u82b1\u5f0f\u7d22\u5f15<br \/>\nb &#061; np.arange(12).reshape(3, 4)<br \/>\nprint(f&#034;\u539f\u6570\u7ec4&#xff1a;\\\\n{b}&#034;)<\/p>\n<p># \u9009\u53d6\u7279\u5b9a\u884c<br \/>\nprint(f&#034;b[[0, 2], :] &#061; \\\\n{b[[0, 2], :]}&#034;) # \u9009\u53d6\u7b2c1\u884c\u548c\u7b2c3\u884c&#xff0c;\u56e0\u4e3a\u4e0b\u6807\u4ece0\u5f00\u59cb\u6240\u4ee5\u662f0\u548c2<\/p>\n<hr \/>\n<h3>3\u3001\u6570\u7ec4\u8fd0\u7b97\u4e0e\u805a\u5408<\/h3>\n<h4>3.1 \u9010\u5143\u7d20\u8fd0\u7b97<\/h4>\n<p>NumPy\u7684\u6838\u5fc3\u4f18\u52bf\u4e4b\u4e00\u662f\u652f\u6301\u5411\u91cf\u5316\u8fd0\u7b97&#xff0c;\u65e0\u9700\u5faa\u73af\u5373\u53ef\u5bf9\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97&#xff1a;<\/p>\n<p>a &#061; np.array([1, 2, 3, 4, 5])<\/p>\n<p># \u57fa\u672c\u7b97\u672f\u8fd0\u7b97<br \/>\nprint(f&#034;a &#043; 10 &#061; {a &#043; 10}&#034;) # [11 12 13 14 15]<br \/>\nprint(f&#034;a &#8211; 5 &#061; {a &#8211; 5}&#034;) # [-4 -3 -2 -1 0]<br \/>\nprint(f&#034;a * 2 &#061; {a * 2}&#034;) # [2 4 6 8 10]<br \/>\nprint(f&#034;a \/ 2 &#061; {a \/ 2}&#034;) # [0.5 1. 1.5 2. 2.5]<br \/>\nprint(f&#034;a ** 2 &#061; {a ** 2}&#034;) # [1 4 9 16 25]<br \/>\nprint(f&#034;a % 2 &#061; {a % 2}&#034;) # [1 0 1 0 1] &#8211; \u53d6\u6a21<\/p>\n<p># \u6bd4\u8f83\u8fd0\u7b97&#xff08;\u5e03\u5c14\u7d22\u5f15&#xff09;<br \/>\nprint(f&#034;a &gt; 3 &#061; {a &gt; 3}&#034;) # [False False False True True]<br \/>\nprint(f&#034;a &#061;&#061; 3 &#061; {a &#061;&#061; 3}&#034;) # [False False True False False]<\/p>\n<p>&#x1f4a1;<span style=\"color:#444444\">\u5411\u91cf\u5316\u4f18\u52bf<\/span><span style=\"color:#444444\">&#xff1a;\u4f7f\u7528\u5411\u91cf\u5316\u8fd0\u7b97\u6bd4<\/span><span style=\"color:#444444\">Python<\/span><span style=\"color:#444444\">\u5faa\u73af\u5feb<\/span><span style=\"color:#444444\">10-100<\/span><span style=\"color:#444444\">\u500d&#xff0c;\u56e0\u4e3a<\/span><span style=\"color:#444444\">NumPy<\/span><span style=\"color:#444444\">\u5728\u5e95\u5c42\u4f7f\u7528\u4e86<\/span><span style=\"color:#444444\">SIMD<\/span><span style=\"color:#444444\">\u6307\u4ee4\u96c6\u4f18<\/span><span style=\"color:#444444\">\u5316\u3002<\/span><\/p>\n<h4>3.2 \u6570\u7ec4\u95f4\u8fd0\u7b97<\/h4>\n<p>\u4e24\u4e2a\u5f62\u72b6\u76f8\u540c\u7684\u6570\u7ec4\u53ef\u4ee5\u8fdb\u884c\u9010\u5143\u7d20\u8fd0\u7b97&#xff1a;<\/p>\n<p>a &#061; np.array([1, 2, 3, 4])<br \/>\nb &#061; np.array([10, 20, 30, 40])<\/p>\n<p>print(f&#034;a &#043; b &#061; {a &#043; b}&#034;) # [11 22 33 44]<br \/>\nprint(f&#034;a * b &#061; {a * b}&#034;) # [10 40 90 160]<br \/>\nprint(f&#034;b &#8211; a &#061; {b &#8211; a}&#034;) # [9 18 27 36]<\/p>\n<h4>3.3 \u5e7f\u64ad\u673a\u5236&#xff08;Boardcasting&#xff09;<\/h4>\n<p>\u5e7f\u64ad NumPy \u6700\u5f3a\u5927\u7684\u7279\u5f81\u4e4b\u4e00&#xff0c;\u5b83\u5141\u8bb8\u4e0d\u540c\u5f62\u72b6\u7684\u6570\u7ec4\u8fdb\u884c\u8fd0\u7b97&#xff1a;<\/p>\n<p># \u4e00\u7ef4\u6570\u7ec4\u4e0e\u4e8c\u7ef4\u6570\u7ec4\u5e7f\u64ad<br \/>\nc &#061; np.array([<br \/>\n    [1, 2, 3],<br \/>\n    [4, 5, 6]<br \/>\n])<br \/>\nd &#061; np.array([10, 20, 30])<\/p>\n<p>print(f&#034;c &#043; d &#061; \\\\n{c &#043; d}&#034;)<br \/>\n# [[11 22 33]<br \/>\n# [14 25 36]]<\/p>\n<p># \u6807\u91cf\u4e0e\u6570\u7ec4\u5e7f\u64ad<br \/>\nprint(f&#034;c * 2 &#061; \\\\n{c * 2}&#034;)<br \/>\n# [[2 4 6]<br \/>\n# [8 10 12]]<\/p>\n<p>&#x1f4a1;<span style=\"color:#444444\">\u5e7f\u64ad\u89c4\u5219<\/span><span style=\"color:#444444\">&#xff1a;\u5f53\u4e24\u4e2a\u6570\u7ec4\u7684\u5f62\u72b6\u4e0d\u540c\u65f6&#xff0c;<\/span><span style=\"color:#444444\">NumPy<\/span><span style=\"color:#444444\">\u4f1a\u4ece\u540e\u5411\u524d\u6bd4\u8f83\u7ef4\u5ea6&#xff0c;\u5982\u679c\u7ef4\u5ea6\u76f8\u540c\u6216\u5176\u4e2d\u4e00\u4e2a\u4e3a<\/span><span style=\"color:#444444\">1<\/span><span style=\"color:#444444\">&#xff0c;<\/span><span style=\"color:#444444\">\u5219\u53ef\u4ee5\u5e7f\u64ad\u3002<\/span><\/p>\n<h4>3.4 \u805a\u5408\u51fd\u6570<\/h4>\n<p>NumPy \u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u805a\u5408\u51fd\u6570&#xff0c;\u7528\u4e8e\u7edf\u8ba1\u8ba1\u7b97&#xff1a;<\/p>\n<p>arr &#061; np.array([1, 2, 3, 4, 5])<\/p>\n<p># \u57fa\u672c\u7edf\u8ba1<br \/>\nprint(f&#034;\u603b\u548c sum &#061; {arr.sum()}&#034;) # 15<br \/>\nprint(f&#034;\u5747\u503c mean &#061; {arr.mean()}&#034;) # 3.0<\/p>\n<p>print(f&#034;\u6700\u5927\u503c max &#061; {arr.max()}&#034;) # 5<br \/>\nprint(f&#034;\u6700\u5c0f\u503c min &#061; {arr.min()}&#034;) # 1<\/p>\n<p>print(f&#034;\u6807\u51c6\u5dee std &#061; {arr.std():.4f}&#034;) # 1.4142<br \/>\nprint(f&#034;\u65b9\u5dee var &#061; {arr.var():.4f}&#034;) # 2.0000<\/p>\n<p># \u7d2f\u79ef\u51fd\u6570<br \/>\nprint(f&#034;\u7d2f\u52a0 cumsum &#061; {arr.cumsum()}&#034;) # [1 3 6 10 15]<br \/>\nprint(f&#034;\u7d2f\u4e58 cumprod&#061; {arr.cumprod()}&#034;) # [1 2 6 24 120]<\/p>\n<h4>3.5 \u591a\u7ef4\u6570\u7ec4\u805a\u5408&#xff08;\u8f74\u5411&#xff09;<\/h4>\n<p>\u5bf9\u4e8e\u591a\u7ef4\u6570\u7ec4&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a axis \u53c2\u6570\u6cbf\u7279\u5b9a\u8f74\u8fdb\u884c\u805a\u5408&#xff1a;<\/p>\n<p>m &#061; np.arange(12).reshape(3, 4)<br \/>\nprint(f&#034;\u539f\u6570\u7ec4&#xff1a;\\\\n{m}&#034;)<\/p>\n<p># \u6309\u5217\u805a\u5408&#xff08;axis&#061;0&#xff09;<br \/>\nprint(f&#034;\u6bcf\u5217\u6c42\u548c (axis&#061;0)&#xff1a;{m.sum(axis&#061;0)}&#034;) #[12 15 18 21]<\/p>\n<p># \u6309\u884c\u805a\u5408&#xff08;axis&#061;1&#xff09;<br \/>\nprint(f&#034;\u6bcf\u884c\u6c42\u548c (axis&#061;1)&#xff1a;{m.sum(axis&#061;1)}&#034;) # [ 6 22 38]<\/p>\n<p># \u5176\u4ed6\u8f74\u5411\u805a\u5408<br \/>\nprint(f&#034;\u6bcf\u5217\u6700\u5927\u503c&#xff1a;{m.max(axis&#061;0)}&#034;) # [ 8 9 10 11]<br \/>\nprint(f&#034;\u6bcf\u884c\u5e73\u5747\u503c&#xff1a;{m.mean(axis&#061;1)}&#034;) # [1.5 5.5 9.5]<\/p>\n<p>&#x1f4a1;\u53c2\u6570\u63d0\u793a&#xff1a;axis&#061;1\u8868\u793a\u884c&#xff0c;axis&#061;0\u8868\u793a\u5217<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e8c\u3001NumPy\u6570\u636e\u5904\u74061\u3001Numpy\u57fa\u7840\u4e0e\u6570\u7ec4\u521b\u5efa1.1 Numpy\u57fa\u7840\u77e5\u8bc6Numpy&#xff08;Numerical Python&#xff09;\u662fPython\u7f16\u7a0b\u8bed\u8a00\u91cc\u9762\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\u7684\u57fa\u7840\u5e93&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61 narray \u4ee5\u53ca\u4e00\u7cfb\u5217\u7528\u4e8e\u64cd\u4f5c\u8fd9\u7c7b\u6570\u7ec4\u7684\u5de5\u5177\u51fd\u6570\u3002NumPy\u4e8e2005\u5e74\u53d1\u5e03&#xff0c;\u73b0\u5982\u4eca\u5df2\u6210\u4e3aPython\u6570\u636e\u79d1\u5b66\u751f\u6001\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u4ef6\u3002&#x1f4a1;\u91cd\u8981\u63d0\u793a&#xff1a;pandas\u3001scipy\u3001scikit-learn<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1818,50,207],"topic":[],"class_list":["post-111019","post","type-post","status-publish","format-standard","hentry","category-server","tag-numpy","tag-50","tag-207"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/111019.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e8c\u3001NumPy\u6570\u636e\u5904\u74061\u3001Numpy\u57fa\u7840\u4e0e\u6570\u7ec4\u521b\u5efa1.1 Numpy\u57fa\u7840\u77e5\u8bc6Numpy&#xff08;Numerical Python&#xff09;\u662fPython\u7f16\u7a0b\u8bed\u8a00\u91cc\u9762\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\u7684\u57fa\u7840\u5e93&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61 narray \u4ee5\u53ca\u4e00\u7cfb\u5217\u7528\u4e8e\u64cd\u4f5c\u8fd9\u7c7b\u6570\u7ec4\u7684\u5de5\u5177\u51fd\u6570\u3002NumPy\u4e8e2005\u5e74\u53d1\u5e03&#xff0c;\u73b0\u5982\u4eca\u5df2\u6210\u4e3aPython\u6570\u636e\u79d1\u5b66\u751f\u6001\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u4ef6\u3002&#x1f4a1;\u91cd\u8981\u63d0\u793a&#xff1a;pandas\u3001scipy\u3001scikit-learn\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/111019.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-29T22:24:43+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/111019.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/111019.html\",\"name\":\"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-29T22:24:43+00:00\",\"dateModified\":\"2026-09-29T22:24:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/111019.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/111019.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/111019.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/111019.html","og_locale":"zh_CN","og_type":"article","og_title":"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e8c\u3001NumPy\u6570\u636e\u5904\u74061\u3001Numpy\u57fa\u7840\u4e0e\u6570\u7ec4\u521b\u5efa1.1 Numpy\u57fa\u7840\u77e5\u8bc6Numpy&#xff08;Numerical Python&#xff09;\u662fPython\u7f16\u7a0b\u8bed\u8a00\u91cc\u9762\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\u7684\u57fa\u7840\u5e93&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61 narray \u4ee5\u53ca\u4e00\u7cfb\u5217\u7528\u4e8e\u64cd\u4f5c\u8fd9\u7c7b\u6570\u7ec4\u7684\u5de5\u5177\u51fd\u6570\u3002NumPy\u4e8e2005\u5e74\u53d1\u5e03&#xff0c;\u73b0\u5982\u4eca\u5df2\u6210\u4e3aPython\u6570\u636e\u79d1\u5b66\u751f\u6001\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u4ef6\u3002&#x1f4a1;\u91cd\u8981\u63d0\u793a&#xff1a;pandas\u3001scipy\u3001scikit-learn","og_url":"https:\/\/www.wsisp.com\/helps\/111019.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-29T22:24:43+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/111019.html","url":"https:\/\/www.wsisp.com\/helps\/111019.html","name":"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-29T22:24:43+00:00","dateModified":"2026-09-29T22:24:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/111019.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/111019.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/111019.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u673a\u5668\u5b66\u4e60\u4e4bNumpy\uff08Machine Learning about Numpy\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/111019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=111019"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/111019\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=111019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=111019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=111019"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=111019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}