{"id":1004683,"date":"2024-12-27T10:28:45","date_gmt":"2024-12-27T02:28:45","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1004683.html"},"modified":"2024-12-27T10:28:49","modified_gmt":"2024-12-27T02:28:49","slug":"python%e5%a6%82%e4%bd%95%e8%af%bb%e5%8f%96%e6%95%b0%e6%8d%ae%e7%bb%b4%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1004683.html","title":{"rendered":"python\u5982\u4f55\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25081524\/4754be61-15b1-4c76-8ef2-c716b57a74b6.webp\" alt=\"python\u5982\u4f55\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\u7684\u65b9\u5f0f\u4e3b\u8981\u6709\u51e0\u79cd\uff1a\u4f7f\u7528NumPy\u5e93\u3001\u4f7f\u7528Pandas\u5e93\u3001\u4f7f\u7528TensorFlow\u5e93\u3002\u5728\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u4e2d\uff0c\u7406\u89e3\u6570\u636e\u7684\u7ef4\u5ea6\u5bf9\u4e8e\u6b63\u786e\u5730\u8fdb\u884c\u6570\u636e\u64cd\u4f5c\u81f3\u5173\u91cd\u8981\u3002NumPy\u7684<code>shape<\/code>\u5c5e\u6027\u3001Pandas\u7684<code>shape<\/code>\u5c5e\u6027\u548cTensorFlow\u7684<code>shape<\/code>\u5c5e\u6027\u662f\u5e38\u7528\u7684\u65b9\u6cd5\u3002<\/strong>\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\uff0c\u5373\u4f7f\u7528NumPy\u5e93\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><p>NumPy\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u80fd\u591f\u65b9\u4fbf\u5730\u8fdb\u884c\u77e9\u9635\u548c\u6570\u7ec4\u64cd\u4f5c\u3002\u8981\u8bfb\u53d6\u6570\u636e\u7684\u7ef4\u5ea6\uff0c\u9996\u5148\u9700\u8981\u4e86\u89e3NumPy\u6570\u7ec4\u7684\u57fa\u672c\u5c5e\u6027\uff0c<code>shape<\/code>\u5c5e\u6027\u662f\u6700\u5e38\u7528\u7684\uff0c\u7528\u4e8e\u8fd4\u56de\u6570\u7ec4\u7684\u7ef4\u5ea6\u3002\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528<code>array.shape<\/code>\u6765\u83b7\u53d6\u8be5\u6570\u7ec4\u7684\u884c\u6570\u548c\u5217\u6570\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\u7684\u64cd\u4f5c\u901a\u5e38\u662f\u4e3a\u4e86\u8fdb\u4e00\u6b65\u7684\u6570\u636e\u5904\u7406\uff0c\u6bd4\u5982\u6570\u636e\u6e05\u6d17\u3001\u7279\u5f81\u63d0\u53d6\u6216\u6a21\u578b\u8f93\u5165\u51c6\u5907\u3002\u56e0\u6b64\uff0c\u4e86\u89e3\u548c\u638c\u63e1\u8fd9\u4e9b\u57fa\u672c\u64cd\u4f5c\u5bf9\u6570\u636e\u79d1\u5b66\u5bb6\u548c\u5de5\u7a0b\u5e08\u6765\u8bf4\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684\u5e93\u548c\u65b9\u6cd5\u6765\u8bfb\u53d6\u6570\u636e\u7684\u7ef4\u5ea6\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001NUMPY\u5e93\u4e2d\u7684\u6570\u636e\u7ef4\u5ea6\u8bfb\u53d6<\/p>\n<\/p>\n<p><p>NumPy\u662f\u4e00\u4e2a\u57fa\u7840\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u5176\u6570\u7ec4\u5bf9\u8c61<code>ndarray<\/code>\u662f\u7528\u4e8e\u8868\u793a\u591a\u7ef4\u6570\u7ec4\u7684\u6838\u5fc3\u5bf9\u8c61\u3002NumPy\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u83b7\u53d6\u6570\u7ec4\u7684\u7ef4\u5ea6\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528<code>shape<\/code>\u5c5e\u6027<\/li>\n<\/ol>\n<p><p>NumPy\u6570\u7ec4\u7684<code>shape<\/code>\u5c5e\u6027\u662f\u7528\u4e8e\u83b7\u53d6\u6570\u7ec4\u7ef4\u5ea6\u7684\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002<code>shape<\/code>\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u6570\u7ec4\u6bcf\u4e00\u7ef4\u5ea6\u5927\u5c0f\u7684\u5143\u7ec4\u3002\u5bf9\u4e8e\u4e8c\u7ef4\u6570\u7ec4\uff0c<code>shape<\/code>\u4f1a\u8fd4\u56de\u4e00\u4e2a\u5f62\u5982<code>(rows, columns)<\/code>\u7684\u5143\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a2x3\u7684\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array = np.array([[1, 2, 3], [4, 5, 6]])<\/p>\n<h2><strong>\u83b7\u53d6\u6570\u7ec4\u7684\u7ef4\u5ea6<\/strong><\/h2>\n<p>dimensions = array.shape<\/p>\n<p>print(&quot;Array dimensions:&quot;, dimensions)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>shape<\/code>\u8fd4\u56de\u7684\u7ed3\u679c\u662f<code>(2, 3)<\/code>\uff0c\u8868\u793a\u8fd9\u4e2a\u6570\u7ec4\u67092\u884c\u548c3\u5217\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528<code>ndim<\/code>\u5c5e\u6027<\/li>\n<\/ol>\n<p><p><code>ndim<\/code>\u5c5e\u6027\u8fd4\u56de\u6570\u7ec4\u7684\u7ef4\u6570\uff08\u8f74\u7684\u4e2a\u6570\uff09\u3002\u5bf9\u4e8e\u4e8c\u7ef4\u6570\u7ec4\uff0c<code>ndim<\/code>\u7684\u503c\u4e3a2\uff0c\u5bf9\u4e8e\u4e09\u7ef4\u6570\u7ec4\uff0c<code>ndim<\/code>\u7684\u503c\u4e3a3\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u83b7\u53d6\u6570\u7ec4\u7684\u7ef4\u6570<\/p>\n<p>dimension_count = array.ndim<\/p>\n<p>print(&quot;Number of dimensions:&quot;, dimension_count)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>ndim<\/code>\u8fd4\u56de2\uff0c\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001PANDAS\u5e93\u4e2d\u7684\u6570\u636e\u7ef4\u5ea6\u8bfb\u53d6<\/p>\n<\/p>\n<p><p>Pandas\u662f\u7528\u4e8e\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\u7684\u9ad8\u7ea7\u5e93\uff0c\u4e3b\u8981\u7528\u4e8e\u5904\u7406\u8868\u683c\u6570\u636e\u3002Pandas\u7684\u6838\u5fc3\u6570\u636e\u7ed3\u6784\u662f<code>DataFrame<\/code>\u548c<code>Series<\/code>\uff0c\u5176\u4e2d<code>DataFrame<\/code>\u7c7b\u4f3c\u4e8e\u4e8c\u7ef4\u6570\u7ec4\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528<code>shape<\/code>\u5c5e\u6027<\/li>\n<\/ol>\n<p><p>\u4e0eNumPy\u7c7b\u4f3c\uff0cPandas\u7684<code>DataFrame<\/code>\u4e5f\u6709<code>shape<\/code>\u5c5e\u6027\uff0c\u7528\u4e8e\u83b7\u53d6\u6570\u636e\u7684\u884c\u6570\u548c\u5217\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aDataFrame<\/strong><\/h2>\n<p>data = {&#39;A&#39;: [1, 2, 3], &#39;B&#39;: [4, 5, 6]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u83b7\u53d6DataFrame\u7684\u7ef4\u5ea6<\/strong><\/h2>\n<p>dimensions = df.shape<\/p>\n<p>print(&quot;DataFrame dimensions:&quot;, dimensions)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>shape<\/code>\u8fd4\u56de<code>(3, 2)<\/code>\uff0c\u8868\u793a\u8fd9\u4e2aDataFrame\u67093\u884c\u548c2\u5217\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528<code>ndim<\/code>\u5c5e\u6027<\/li>\n<\/ol>\n<p><p>Pandas\u7684<code>DataFrame<\/code>\u4e5f\u6709<code>ndim<\/code>\u5c5e\u6027\uff0c\u4f46\u56e0\u4e3a<code>DataFrame<\/code>\u59cb\u7ec8\u662f\u4e8c\u7ef4\u7684\uff0c\u6240\u4ee5<code>ndim<\/code>\u7684\u503c\u603b\u662f2\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u83b7\u53d6DataFrame\u7684\u7ef4\u6570<\/p>\n<p>dimension_count = df.ndim<\/p>\n<p>print(&quot;Number of dimensions:&quot;, dimension_count)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001TENSORFLOW\u5e93\u4e2d\u7684\u6570\u636e\u7ef4\u5ea6\u8bfb\u53d6<\/p>\n<\/p>\n<p><p>TensorFlow\u662f\u4e00\u4e2a\u7528\u4e8e<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u548c\u6df1\u5ea6\u5b66\u4e60\u7684\u5f00\u6e90\u6846\u67b6\u3002\u5176\u6838\u5fc3\u6570\u636e\u7ed3\u6784\u662f<code>Tensor<\/code>\uff0c\u7c7b\u4f3c\u4e8eNumPy\u7684<code>ndarray<\/code>\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528<code>shape<\/code>\u5c5e\u6027<\/li>\n<\/ol>\n<p><p>TensorFlow\u7684<code>Tensor<\/code>\u5bf9\u8c61\u4e5f\u6709<code>shape<\/code>\u5c5e\u6027\uff0c\u7528\u4e8e\u8fd4\u56de\u5f20\u91cf\u7684\u7ef4\u5ea6\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tensorflow as tf<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5f20\u91cf<\/strong><\/h2>\n<p>tensor = tf.constant([[1, 2, 3], [4, 5, 6]])<\/p>\n<h2><strong>\u83b7\u53d6\u5f20\u91cf\u7684\u7ef4\u5ea6<\/strong><\/h2>\n<p>dimensions = tensor.shape<\/p>\n<p>print(&quot;Tensor dimensions:&quot;, dimensions)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>shape<\/code>\u8fd4\u56de<code>(2, 3)<\/code>\uff0c\u8868\u793a\u8fd9\u4e2a\u5f20\u91cf\u67092\u884c\u548c3\u5217\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528<code>rank<\/code>\u65b9\u6cd5<\/li>\n<\/ol>\n<p><p>\u5728TensorFlow\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>tf.rank()<\/code>\u51fd\u6570\u6765\u83b7\u53d6\u5f20\u91cf\u7684\u79e9\uff08\u7ef4\u6570\uff09\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u83b7\u53d6\u5f20\u91cf\u7684\u79e9<\/p>\n<p>rank = tf.rank(tensor)<\/p>\n<p>print(&quot;Tensor rank:&quot;, rank.numpy())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>rank<\/code>\u8fd4\u56de2\uff0c\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u4e8c\u7ef4\u5f20\u91cf\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5e94\u7528\u573a\u666f\u548c\u5b9e\u9645\u6848\u4f8b<\/p>\n<\/p>\n<p><p>\u5728\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u8bfb\u53d6\u6570\u636e\u7684\u7ef4\u5ea6\u662f\u6570\u636e\u9884\u5904\u7406\u7684\u91cd\u8981\u6b65\u9aa4\u4e4b\u4e00\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6570\u636e\u6e05\u6d17\u548c\u6574\u7406<\/li>\n<\/ol>\n<p><p>\u5728\u6570\u636e\u6e05\u6d17\u8fc7\u7a0b\u4e2d\uff0c\u4e86\u89e3\u6570\u636e\u7684\u7ef4\u5ea6\u6709\u52a9\u4e8e\u68c0\u6d4b\u6570\u636e\u4e2d\u7684\u7f3a\u5931\u503c\u548c\u5f02\u5e38\u503c\u3002\u901a\u8fc7\u68c0\u67e5\u6570\u636e\u7684\u884c\u6570\u548c\u5217\u6570\uff0c\u53ef\u4ee5\u786e\u4fdd\u6570\u636e\u96c6\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u7279\u5f81\u5de5\u7a0b<\/li>\n<\/ol>\n<p><p>\u5728\u7279\u5f81\u5de5\u7a0b\u4e2d\uff0c\u6570\u636e\u7684\u7ef4\u5ea6\u76f4\u63a5\u5f71\u54cd\u7279\u5f81\u9009\u62e9\u548c\u7279\u5f81\u63d0\u53d6\u7684\u7b56\u7565\u3002\u5bf9\u4e8e\u9ad8\u7ef4\u6570\u636e\uff0c\u53ef\u80fd\u9700\u8981\u91c7\u7528\u964d\u7ef4\u6280\u672f\u4ee5\u964d\u4f4e\u6570\u636e\u7684\u590d\u6742\u6027\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\u6a21\u578b\u8f93\u5165\u51c6\u5907<\/li>\n<\/ol>\n<p><p>\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u4e0d\u540c\u7684\u6a21\u578b\u5bf9\u8f93\u5165\u6570\u636e\u7684\u7ef4\u5ea6\u6709\u4e0d\u540c\u7684\u8981\u6c42\u3002\u4e86\u89e3\u6570\u636e\u7684\u7ef4\u5ea6\u6709\u52a9\u4e8e\u6b63\u786e\u5730\u51c6\u5907\u8bad\u7ec3\u6570\u636e\uff0c\u4ee5\u5339\u914d\u6a21\u578b\u7684\u8f93\u5165\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u6ce8\u610f\u4e8b\u9879\u548c\u6700\u4f73\u5b9e\u8df5<\/p>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\u65f6\uff0c\u6709\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\u548c\u6700\u4f73\u5b9e\u8df5\u53ef\u4ee5\u5e2e\u52a9\u63d0\u9ad8\u6548\u7387\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u786e\u4fdd\u6570\u636e\u683c\u5f0f\u6b63\u786e<\/li>\n<\/ol>\n<p><p>\u5728\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\u4e4b\u524d\uff0c\u786e\u4fdd\u6570\u636e\u683c\u5f0f\u6b63\u786e\u5e76\u7b26\u5408\u9884\u671f\u3002\u5bf9\u4e8eNumPy\u6570\u7ec4\u548cPandas DataFrame\uff0c\u6570\u636e\u5fc5\u987b\u662f\u7ed3\u6784\u5316\u7684\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528\u5408\u9002\u7684\u5de5\u5177<\/li>\n<\/ol>\n<p><p>\u6839\u636e\u6570\u636e\u7684\u7c7b\u578b\u548c\u5e94\u7528\u573a\u666f\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u5e93\u3002\u5bf9\u4e8e\u591a\u7ef4\u6570\u7ec4\u64cd\u4f5c\uff0cNumPy\u662f\u9996\u9009\uff1b\u5bf9\u4e8e\u8868\u683c\u6570\u636e\uff0cPandas\u66f4\u4e3a\u9002\u5408\uff1b\u800c\u5bf9\u4e8e\u6df1\u5ea6\u5b66\u4e60\u4e2d\u7684\u5f20\u91cf\u64cd\u4f5c\uff0cTensorFlow\u5219\u66f4\u4e3a\u5408\u9002\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e<\/li>\n<\/ol>\n<p><p>\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u96c6\uff0c\u8bfb\u53d6\u548c\u5904\u7406\u6570\u636e\u7684\u7ef4\u5ea6\u53ef\u80fd\u4f1a\u6d88\u8017\u5927\u91cf\u5185\u5b58\u548c\u8ba1\u7b97\u8d44\u6e90\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5206\u5e03\u5f0f\u8ba1\u7b97\u6846\u67b6\uff08\u5982Dask\u6216Spark\uff09\u6765\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\u548c\u5b9e\u8df5\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u8bfb\u53d6\u548c\u7406\u89e3\u6570\u636e\u7684\u7ef4\u5ea6\u4fe1\u606f\uff0c\u8fd9\u5bf9\u4e8e\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u5efa\u6a21\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u65e0\u8bba\u662f\u79d1\u5b66\u8ba1\u7b97\u3001\u6570\u636e\u5206\u6790\u8fd8\u662f\u673a\u5668\u5b66\u4e60\uff0c\u638c\u63e1\u8fd9\u4e9b\u57fa\u672c\u6280\u80fd\u90fd\u5c06\u6781\u5927\u5730\u5e2e\u52a9\u60a8\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u548c\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u67e5\u770b\u6570\u636e\u7684\u7ef4\u5ea6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u6216Pandas\u5e93\u6765\u8bfb\u53d6\u6570\u636e\u7684\u7ef4\u5ea6\u3002\u5bf9\u4e8eNumPy\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528<code>.shape<\/code>\u5c5e\u6027\u6765\u83b7\u53d6\u7ef4\u5ea6\u4fe1\u606f\u3002\u4f8b\u5982\uff0c<code>array.shape<\/code>\u5c06\u8fd4\u56de\u4e00\u4e2a\u5143\u7ec4\uff0c\u8868\u793a\u6570\u7ec4\u5728\u6bcf\u4e2a\u7ef4\u5ea6\u4e0a\u7684\u5927\u5c0f\u3002\u5bf9\u4e8ePandas\u6570\u636e\u6846\uff0c\u4f7f\u7528<code>dataframe.shape<\/code>\u540c\u6837\u53ef\u4ee5\u83b7\u53d6\u884c\u548c\u5217\u7684\u6570\u91cf\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u5e93\u6765\u5904\u7406\u6570\u636e\u7684\u7ef4\u5ea6\uff1f<\/strong><br \/>\u5904\u7406\u6570\u636e\u7ef4\u5ea6\u65f6\uff0cNumPy\u548cPandas\u662f\u6700\u5e38\u7528\u7684\u5e93\u3002NumPy\u4e13\u6ce8\u4e8e\u9ad8\u6548\u7684\u6570\u503c\u8ba1\u7b97\uff0c\u9002\u5408\u5904\u7406\u591a\u7ef4\u6570\u7ec4\uff1b\u800cPandas\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u6570\u636e\u7ed3\u6784\u548c\u6570\u636e\u5206\u6790\u5de5\u5177\uff0c\u5c24\u5176\u9002\u5408\u5904\u7406\u8868\u683c\u6570\u636e\u3002\u9009\u62e9\u9002\u5408\u7684\u5e93\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u64cd\u4f5c\u7684\u6548\u7387\u548c\u4fbf\u6377\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u8bfb\u53d6\u6570\u636e\u540e\u9a8c\u8bc1\u5176\u7ef4\u5ea6\uff1f<\/strong><br \/>\u5728\u8bfb\u53d6\u6570\u636e\u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5370\u6570\u636e\u7684\u7ef4\u5ea6\u4fe1\u606f\u6765\u9a8c\u8bc1\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>print(data.shape)<\/code>\u53ef\u4ee5\u76f4\u63a5\u770b\u5230\u6570\u636e\u7684\u884c\u6570\u548c\u5217\u6570\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>data.info()<\/code>\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u83b7\u53d6\u6570\u636e\u7684\u6574\u4f53\u7ed3\u6784\uff0c\u5305\u62ec\u975e\u7a7a\u503c\u7684\u6570\u91cf\u548c\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u6709\u52a9\u4e8e\u786e\u4fdd\u6570\u636e\u6b63\u786e\u8bfb\u53d6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u8bfb\u53d6\u6570\u636e\u7ef4\u5ea6\u7684\u65b9\u5f0f\u4e3b\u8981\u6709\u51e0\u79cd\uff1a\u4f7f\u7528NumPy\u5e93\u3001\u4f7f\u7528Pandas\u5e93\u3001\u4f7f\u7528TensorFlow [&hellip;]","protected":false},"author":3,"featured_media":1004694,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1004683"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1004683"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1004683\/revisions"}],"predecessor-version":[{"id":1004697,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1004683\/revisions\/1004697"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1004694"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1004683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1004683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1004683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}