{"id":148,"date":"2019-11-15T16:20:56","date_gmt":"2019-11-15T07:20:56","guid":{"rendered":"http:\/\/aiacademy.jp\/media\/?p=148"},"modified":"2024-08-08T14:55:05","modified_gmt":"2024-08-08T05:55:05","slug":"%e3%80%90%e5%88%9d%e5%bf%83%e8%80%85%e5%90%91%e3%81%91%e3%80%91%e6%95%b0%e5%80%a4%e8%a8%88%e7%ae%97%e3%83%bb%e3%83%87%e3%83%bc%e3%82%bf%e5%87%a6%e7%90%86%e3%81%a7%e5%bf%85%e9%a0%88%e3%81%aenumpy","status":"publish","type":"post","link":"https:\/\/aiacademy.jp\/media\/?p=148","title":{"rendered":"\u3010\u521d\u5fc3\u8005\u5411\u3051\u3011\u6570\u5024\u8a08\u7b97\u30fb\u30c7\u30fc\u30bf\u51e6\u7406\u3067\u5fc5\u9808\u306eNumPy\u3092\u5165\u9580\u3057\u3088\u3046\uff01"},"content":{"rendered":"<div id=\"sgb-css-id-1\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-font-size is-style-fill has-medium-font-size\"><a class=\"wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button\" href=\"https:\/\/lin.ee\/3E4GzWk\" rel=\"nofollow noopener\" target=\"_blank\">LINE\u53cb\u3060\u3061\u767b\u9332 \u25b6 Python\u30b3\u30fc\u30b9 \u25b6 \u53d7\u8b1b\u5272\u5f15\u30af\u30fc\u30dd\u30f3 \u7121\u6599\u52d5\u753b<\/a><\/div>\n<\/div>\n<\/div>\n\n<div class=\"toc\">    <div id=\"toc_container\" class=\"sgb-toc--no-bullets js-smooth-scroll\" data-dialog-title=\"Table of Contents\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">NumPy\u3068\u306f<\/a>  <\/li>  <li>    <a href=\"#i-1\">\u306a\u305cNumPy\u3092\u5b66\u3076\u306e\u304b<\/a>  <\/li>  <li>    <a href=\"#i-2\">NumPy\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a>  <\/li>  <li>    <a href=\"#i-3\">NumPy\u3092\u4f7f\u7528\u3059\u308b<\/a>  <\/li>  <li>    <a href=\"#i-4\">\u914d\u5217(\u30a2\u30ec\u30a4)\u3092\u4f5c\u308b<\/a>  <\/li>  <li>    <a href=\"#i-5\">NumPy\u914d\u5217\u306e\u5f62\u72b6\u3092\u8abf\u3079\u308b<\/a>  <\/li>  <li>    <a href=\"#i-6\">\u914d\u5217\u306e\u751f\u6210 arange()<\/a>  <\/li>  <li>    <a href=\"#i-7\">\u914d\u5217\u64cd\u4f5c<\/a>  <\/li>  <li>    <a href=\"#i-8\">\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8<\/a>  <\/li>  <li>    <a href=\"#i-9\">\u591a\u6b21\u5143\u914d\u5217\u306e\u8a08\u7b97<\/a>  <\/li>  <li>    <a href=\"#i-10\">\u884c\u5217\u3068\u306f<\/a>  <\/li>  <li>    <a href=\"#i-11\">\u884c\u5217 \u6210\u5206<\/a>  <\/li>  <li class=\"last\">    <a href=\"#i-12\">\u307e\u3068\u3081<\/a>  <\/li><\/ul>\n      \n    <\/div><\/div><div class=\"toc\"><p><\/p>\n<\/div><h2 id=\"i-0\">NumPy\u3068\u306f<\/h2>\n<p><strong>NumPy(\u30ca\u30e0\u30d1\u30a4\/\u30ca\u30f3\u30d1\u30a4 \/ Numerical Python)\u306fPython\u3067\u6570\u5024\u8a08\u7b97\u3092\u52b9\u7387\u7684\u306b\u884c\u3046\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3001\u30c7\u30fc\u30bf\u89e3\u6790\u53ca\u3073\u3001\u7dda\u5f62\u4ee3\u6570\u3092\u6271\u3046\u4e0a\u3067\u306f\u5fc5\u9808\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002<\/strong><br><em>NumPy\u3092\u4f7f\u3046\u3053\u3068\u3067\u30d9\u30af\u30c8\u30eb\u3084\u884c\u5217\u306a\u3069\u306e\u591a\u6b21\u5143\u914d\u5217\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/em><br>NumPy\u306f\u3001Matplotlib\u3001Pandas\u3001SciPy\u306a\u3069\u306ePython\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u5408\u308f\u305b\u3066\u3088\u304f\u5229\u7528\u3055\u308c\u307e\u3059\u3002<br><a href=\"http:\/\/docs.scipy.org\/doc\/numpy\/reference\/\" rel=\"nofollow noopener\" target=\"_blank\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/p>\n<h2 id=\"i-1\">\u306a\u305cNumPy\u3092\u5b66\u3076\u306e\u304b<\/h2>\n<p>\u306a\u305cNumPy\u3092\u5b66\u3076\u306e\u304b\u306b\u3064\u3044\u3066\u3042\u3089\u304b\u3058\u3081\u8aac\u660e\u3057\u307e\u3059\u3002<br>NumPy\u306f\u6a5f\u68b0\u5b66\u7fd2\u30fb\u30c7\u30a3\u30fc\u30d7\u30e9\u30fc\u30cb\u30f3\u30b0\u3092\u6271\u3046\u6a5f\u68b0\u5b66\u7fd2\u30a8\u30f3\u30b8\u30cb\u30a2(Python\u30a8\u30f3\u30b8\u30cb\u30a2)\u306b\u53d6\u3063\u3066\u3001\u5fc5\u9808\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3044\u3063\u3066\u3082\u826f\u3044\u304f\u3089\u3044\u3001\u591a\u304f\u5229\u7528\u3057\u307e\u3059\u3002<br><strong>NumPy\u306f\u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u306e\u51e6\u7406\u306b\u512a\u308c\u3066\u304a\u308a\u3001\u6a5f\u68b0\u5b66\u7fd2\u30fb\u30c7\u30a3\u30fc\u30d7\u30e9\u30fc\u30cb\u30f3\u30b0\u306e\u73fe\u5834\u3067\u591a\u304f\u4f7f\u3044\u307e\u3059\u3002<\/strong><br>\u305d\u306e\u305f\u3081NumPy\u306f\u6a5f\u68b0\u5b66\u7fd2\u30a8\u30f3\u30b8\u30cb\u30a2\u306b\u3068\u3063\u3066\u300c\u6700\u521d\u306e\u4e00\u6b69\u300d\u3068\u306a\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u306e\u3067\u3001\u662f\u975e\u3053\u306e\u7ae0\u3067\u3057\u3063\u304b\u308a\u57fa\u790e\u3092\u5b66\u3093\u3067\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2 id=\"i-2\">NumPy\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>pip \u30b3\u30de\u30f3\u30c9\u3092\u7528\u3044\u305f<strong>NumPy<\/strong>\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u51fa\u6765\u307e\u3059\u3002<br>Mac\u306e\u65b9\u306f\u30bf\u30fc\u30df\u30ca\u30eb\u3001Windows\u306e\u65b9\u306f\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u4e0a\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre><code class=\"shell\">pip install numpy\n<\/code><\/pre>\n<p>Jupyter Notebook\u3092\u304a\u4f7f\u3044\u306e\u65b9\u306f\u3001\u8d77\u52d5\u3057\u305fNotebook\u306e\u30bb\u30eb\u306b\u3001\u5148\u982d\u306b!\u30de\u30fc\u30af\u3092\u3064\u3051\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre><code class=\"shell\">!pip install numpy\n<\/code><\/pre>\n<h2 id=\"i-3\">NumPy\u3092\u4f7f\u7528\u3059\u308b<\/h2>\n<p>import\u6587\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u3001NumPy\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre><code>import numpy as  np\n<\/code><\/pre>\n<h2 id=\"i-4\">\u914d\u5217(\u30a2\u30ec\u30a4)\u3092\u4f5c\u308b<\/h2>\n<p>array()\u3092\u4f7f\u3046\u3053\u3068\u3067NumPy\u306e\u914d\u5217\u3092\u4f5c\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre><code>import numpy as  np\nx = np.array([1.0, 2.0, 3.0, 4.0, 5.0])\nprint(x)\n# array()\u306f\u3001Python\u306e\u30ea\u30b9\u30c8\u3092\u6e21\u3059\u3053\u3068\u3067NumPy \u7528\u306e\u914d\u5217(numpy.ndarray)\u3092\u751f\u6210\u3057\u307e\u3059\u3002\n\nx = np.array([1,2,3])\nprint(x) # [1 2 3]\nprint(type(x)) # &lt;class 'numpy.ndarray'&gt;\n\nmy_list1 = [1,2,3,4,5]\nmy_array1 = np.array(my_list1) # numpy\u306earray\u3092\u4f5c\u308b\n\nmy_list2 = [10,20,30,40,50]\nmy_lists = [my_list1, my_list2] # \u30ea\u30b9\u30c8\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u308b\u3002\nmy_lists # [[1, 2, 3, 4, 5], [10, 20, 30, 40, 50]] # \u30ea\u30b9\u30c8\u306e\u30ea\u30b9\u30c8\u304c\u5b8c\u6210\u3002\n\n# my_lists\u3092\u4f7f\u3063\u3066NumPy\u306e\u30a2\u30ec\u30a4\u3092\u4f7f\u308b\u3002\uff08\u591a\u6b21\u5143\u914d\u5217\u3092\u4f5c\u308b\uff09\nmy_array2 = np.array(my_lists)\n\nmy_array2 # 2\u884c5\u5217\u306e\u914d\u5217\u304c\u3067\u304d\u308b\u3002\n\"\"\"\narray([[ 1,  2,  3,  4,  5],\n       [10, 20, 30, 40, 50]])\n\"\"\"\n\n# \u6b21\u306e\u3088\u3046\u306b\u3001\u30bf\u30d7\u30eb\u3092\u8907\u6570\u6e21\u3059\u3068\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\nnp.array((1,2,3),(4,5,6))\n\n\"\"\"\nTraceback (most recent call last):\n  File \"&lt;stdin&gt;\", line 1, in &lt;module&gt;\nTypeError: data type not understood\n\"\"\"\n<\/code><\/pre>\n<h2 id=\"i-5\">NumPy\u914d\u5217\u306e\u5f62\u72b6\u3092\u8abf\u3079\u308b<\/h2>\n<p>NumPy\u914d\u5217(ndarray)\u306e\u5f62\u72b6\u3092\u8abf\u3079\u308b\u306b\u306f<strong>shape<\/strong>\u3068\u3044\u3046\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u8abf\u3079\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u203b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u3068\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3054\u3068\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u5909\u6570\u306e\u3053\u3068(\u500b\u3005\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u683c\u7d0d\u3055\u308c\u308b\u5909\u6570)\u3067\u3059\u3002<br>\u8a73\u3057\u304f\u306f\u3001<a href=\"?id=18&amp;section=\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\">\u30af\u30e9\u30b9\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/a>\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><code>import numpy as np\na = np.array([1, 2, 3, 4])\na.shape # (4,)\u304c\u51fa\u529b\u3055\u308c\u308b\u3002\u3053\u308c\u306f1\u6b21\u5143\u914d\u5217\u3067\u304b\u3064\u30014\u3064\u8981\u7d20\u304c\u3042\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002\n\nb = np.array([[1, 2],[3,4]])\nb.shape # (2, 2) \u3053\u308c\u306f\u884c\u5217\u3067\u30012\u884c2\u5217\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059\u3002\n<\/code><\/pre>\n<h2 id=\"i-6\">\u914d\u5217\u306e\u751f\u6210 arange()<\/h2>\n<p>arange()\u306fpython\u306efor\u6587\u3067\u4f7f\u3063\u305frange()\u95a2\u6570\u3068\u4f3c\u305f\u95a2\u6570\u3067\u3059\u3002<br>range()\u540c\u69d8\u306b\u5f15\u6570\u306b\u6e21\u3057\u305f\u6570\u306e\u914d\u5217\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><code>import numpy as  np\n# \u30c7\u30fc\u30bf\u306e\u6e96\u5099\n# \u7b49\u9593\u9694\u306e\u6570\u5b57\n# 0\u304b\u30899\u307e\u3067\u306e\u6570\u5b57(\u914d\u5217)\u3092\u751f\u6210\nx = np.arange(10)\nprint(x)\n\n# reshape()\u306f\u914d\u5217\u3092\u5f62\u72b6\u306b\u5909\u63db\u3057\u307e\u3059\nx = np.arange(1, 10).reshape(3,3) # 3\u00d73\u306e\u591a\u6b21\u5143\u914d\u5217\u306b\u5909\u63db\ny = np.arange(1, 10).reshape(3,3) # 3\u00d73\u306e\u591a\u6b21\u5143\u914d\u5217\u306b\u5909\u63db\n\"\"\"\nx\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u3082\u53ef\u80fd\nx = np.reshape(x, (3,3))\n\"\"\"\nprint(x)\nprint(y)\n\nprint(x + y)\nprint(x - y)\nprint(x * y)\n<\/code><\/pre>\n<h2 id=\"i-7\">\u914d\u5217\u64cd\u4f5c<\/h2>\n<p>NumPy\u3067\u306f\u518d\u5f62\u6210\u3068\u3044\u3063\u3066\u3001\u914d\u5217\u306e\u6b21\u5143\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre><code>import numpy as np\nsample_array = np.arange(10)\nprint(sample_array)\n\n# reshape\u3092\u4f7f\u3063\u3066\u914d\u5217\u306e\u5f62\u72b6\u3092\u6307\u5b9a\nsample_array2 = sample_array.reshape(2,5)\nprint(sample_array2) #array(([0,1,2,3,4],[5,6,7,8,9]])\n\n# concatenate\u3092\u4f7f\u3063\u3066\u3001\u30c7\u30fc\u30bf\u306e\u7d50\u5408\u3059\u308b(axis\u3067\u884c\u65b9\u5411\u304b\u3001\u7e26\u65b9\u5411\u3092\u6307\u5b9a\u53ef\u80fd)\nsample_array3 = np.array([[1,2,3],[4,5,6]])\nsample_array4 = np.array([[7,8,9],[10,11,12]])\n\n# \u884c\u65b9\u5411\u306b\u7d50\u5408 ([[1,2,3,7,8,9],4,5,6,10,11,12]])\nprint(np.concatenate([sample_array3,sample_array4],axis=1))\n\n# hstack\u3067\u3082\u884c\u65b9\u5411\u306e\u7d50\u5408\u304c\u53ef\u80fd\nprint(np.hstack((sample_array3,sample_array4)))\n\n\n\n\"\"\"\naxis=0\u3067\u5217\u65b9\u5411\naxis=1\u3067\u884c\u65b9\u5411\u3067\u3059\u3002\n\u4e0b\u8a18URL\u3092\u53c2\u8003\u304f\u3060\u3055\u3044\u3002\nhttps:\/\/qiita.com\/shuetsu@github\/items\/2bf8bba233c5ecc7a0ad\n\"\"\"\n\n# axis\u306b0\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u5217\u65b9\u5411 ([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])\nprint(np.concatenate([sample_array3,sample_array4],axis=0))\n\n# vstack\u3067\u5217\u65b9\u5411\u306e\u7d50\u5408\u304c\u53ef\u80fd\nprint(np.vstack((sample_array3,sample_array4)))\n<\/code><\/pre>\n<h2 id=\"i-8\">\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8<\/h2>\n<p><strong>\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u306f\u3001\u914d\u5217\u306e\u5927\u304d\u3055\u304c\u7570\u306a\u3063\u3066\u3044\u308c\u3070\u3001\u81ea\u52d5\u7684\u306b\u8981\u7d20\u3092\u30b3\u30d4\u30fc\u3057\u5927\u304d\u3055\u3092\u63c3\u3048\u308bNumPy\u306e\u6a5f\u80fd\u3067\u3059\u3002<\/strong><\/p>\n<pre><code>import numpy as np\n# \u30c7\u30fc\u30bf\u306e\u6e96\u5099\nsample_array = np.arange(10)\nprint(sample_array)\n\n# \u4e0a\u8a18\u306e\u914d\u5217\u306b\u300c5\u300d\u3092\u8db3\u3059\u8a08\u7b97\n# \u8981\u7d20\u3092\u30b3\u30d4\u30fc\u3057\u3066\u5927\u304d\u3055\u3092\u63c3\u3048\u3066\u3001\u914d\u5217\u306e\u5168\u3066\u306e\u8981\u7d20\u306b5\u3092\u52a0\u7b97\nprint(sample_array + 5)\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/bd16245d17b1cbfaa7a9f267de2d8dae8ef39cec\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3137313731352f65393664663264642d353937342d353662312d313239652d3236373162383062343535642e706e67\" alt=\"\"><\/p>\n<h2 id=\"i-9\">\u591a\u6b21\u5143\u914d\u5217\u306e\u8a08\u7b97<\/h2>\n<p>\u591a\u6b21\u5143\u914d\u5217\u3068\u306f\u3001\u6570\u5b57\u306e\u96c6\u5408\u3067\u3042\u308a\u3001N\u6b21\u5143\u72b6\u306b\u6570\u5b57\u3092\u4e26\u3079\u305f\u3082\u306e\u3067\u3059\u3002<br>\u6570\u5b57\u304c1\u5217\u306b\u4e26\u3093\u3060\u308a\u3001\u9577\u65b9\u5f62\u72b6\u306b\u4e26\u3079\u305f\u308a\u30013\u6b21\u5143\u72b6\u306b\u4e26\u3079\u305f\u3082\u306e\u306a\u3069\u3067\u3059\u3002<br>1\u6b21\u5143\u30012\u6b21\u5143\u30013\u6b21\u5143\u3001\u30fb\u30fb\u30fbN\u6b21\u5143<\/p>\n<pre><code>import numpy as np\n\nn1 = np.array([1,2,3,4,5])\nprint(n1) # [1 2 3 4 5]\n\n# \u914d\u5217\u306e\u6b21\u5143\u6570\u306f np.ndim() \u95a2\u6570\u3067\u53d6\u5f97\u53ef\u80fd\nnp.ndim(n1) # 1 -&gt; 1\u6b21\u5143\n\n# \u914d\u5217\u306e\u5f62\u72b6\u53d6\u5f97\u306b\u306fshape\u3092\u4f7f\u3046\u3002\u30bf\u30d7\u30eb\u3067\u304b\u3048\u3063\u3066\u304f\u308b\nn1.shape # (5,) # \u5909\u6570n1\u306e\u5f62\u72b6\u3092\u53d6\u5f97\n\n\"\"\"\n2\u6b21\u5143\u914d\u5217 (5,3)\n\n3\u6b21\u5143\u914d\u5217 (5,5,4)\n\n1\u6b21\u5143\u3067\u30822\u6b21\u5143\u3067\u3082\u3001\u540c\u69d8\u306b\u30bf\u30d7\u30eb\u3067\u7d50\u679c\u304c\u8fd4\u3055\u308c\u308b\u3002\n\"\"\"\n\n# 3\u884c2\u5217\u306e\u914d\u5217\uff082\u6b21\u5143\u306e\u914d\u5217\uff09\u3092\u4f5c\u6210\n\n\"\"\"\n2\u6b21\u5143\u914d\u5217\u306f\u884c\u5217\u306e\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002\n3 \u00d7 2 \u306e\u914d\u5217\u306f\u3001\u6700\u521d\u306e\u6b21\u5143\u306b3\u3064\u8981\u7d20\u304c\u3042\u308a\u3001\n\u6b21\u306e\u6b21\u5143\u306b2\u3064\u306e\u8981\u7d20\u304c\u3042\u308b\u3068\u3044\u3046\u610f\u5473\u3002\n\n\u884c(row) \u914d\u5217\u306e\u6a2a\u65b9\u5411\n\u5217(column) \u914d\u5217\u306e\u7e26\u65b9\u5411\n\"\"\"\n\nn2 = np.array([[1,2], [3,4], [5,6]])\nprint(n2)\n\n\"\"\"\n[[1 2]\n [3 4]\n [5 6]]\n\"\"\"\nprint(n2.ndim) # 2\n<\/code><\/pre>\n<h2 id=\"i-10\">\u884c\u5217\u3068\u306f<\/h2>\n<p>\u884c\u5217\u306f\u3001\u6570\u3084\u8a18\u53f7\u3084\u5f0f\u306a\u3069\u3092\u884c\u3068\u5217\u306b\u6cbf\u3063\u3066\u914d\u5217\u3057\u305f\u3082\u306e\u3067\u3059\u3002<br>\u6570\u5b66\u306e\u7dda\u5f62\u4ee3\u6570\u5b66\u5468\u8fba\u5206\u91ce\u3067\u51fa\u3066\u304d\u307e\u3059\u3002<br>\u65e9\u901f\u4f8b\u3092\u898b\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/9d66dfd790323b9218cc67ab391d29183eaaea20\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3130353838372f31316136333662312d643239642d343337312d343339332d6436303664643235366532662e706e67\" alt=\"\"><\/p>\n<p>\u4e0a\u306e\u56f3\u306f2\u884c5\u5217\uff082\u00d75\u884c\u5217\uff09\u306e\u884c\u5217\u306e\u4f8b\u3067\u3059\u3002<br>\u884c\u5217\u3067\u306f\u3001<br><strong>\u6a2a\u306e\u3053\u3068\u3092\u3001\u884c<\/strong><br><strong>\u7e26\u306e\u3053\u3068\u3092\u3001\u5217<\/strong><br>\u3068\u8a00\u3044\u307e\u3059\u3002<br>\u6b21\u306f\u3001\uff14\u884c\uff12\u5217\u306e\u306e\u884c\u5217\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/1fd62ad483cbe3f061c8282f08a12ae4ec910c2b\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3130353838372f38393935313661332d363964342d393033652d616165642d6535333466663536653132302e706e67\" alt=\"\"><\/p>\n<p>Python\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8868\u3057\u307e\u3059\u3002<\/p>\n<pre><code>import numpy as np\nmy_li1 = [-1,4]\n\nmy_li2 = [3,2]\n\nmy_li3 = [2,5]\n\nmy_li4 = [0,1]\n\nmy_lists = [my_li1,my_li2,my_li3,my_li4]\n\nmy_array3 = np.array(my_lists)\n\nmy_array3\n\"\"\"\narray([[-1,  4],\n       [ 3,  2],\n       [ 2,  5],\n       [ 0,  1]])\n\"\"\"\n<\/code><\/pre>\n<h2 id=\"i-11\">\u884c\u5217 \u6210\u5206<\/h2>\n<p>\u884c\u5217\u306ei\u884cj\u5217\u76ee\u306b\u3042\u308b\u6570\u306e\u3053\u3068\u3092\u3001(i,j)\u6210\u5206\u3068\u547c\u3073\u307e\u3059\u3002<br>\u6570\u5b66\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u884c\u5217\u304c\u3042\u3063\u305f\u5834\u5408\u3001\uff083,2)\u6210\u5206\u306f5\u306b\u306a\u308a\u307e\u3059\u3002<br>\u540c\u69d8\u306b\u3001(4,1)\u6210\u5206\u306f0\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/1fd62ad483cbe3f061c8282f08a12ae4ec910c2b\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3130353838372f38393935313661332d363964342d393033652d616165642d6535333466663536653132302e706e67\" alt=\"\"><\/p>\n<p>\u305f\u3060\u3057\u6570\u5b66\u7684\u306b\u3001\u884c\u5217\u3067\u306f\u8981\u7d20\u306f\u4e00\u756a\u5de6\u4e0a\u306e\u8981\u7d20\u3092(1,1)\u3068\u3057\u307e\u3059\u304c\u3001python\u3067\u306f(0,0)\u3068\u3059\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002(python\u306e\u30ea\u30b9\u30c8\u306b\u304a\u3044\u3066\u3001a = [1,2,3]\u306e\u6642\u3001a[0]\u306f1\u3092\u6307\u3057\u307e\u3059\u3002)<br>\u3088\u3063\u3066\u4e0a\u306e\u884c\u5217\u3092python\u3067\u6271\u3046\u5834\u5408\u3001(0,0)\u306e\u6210\u5206\u306f\u3001-1\u3067\u3059\u3002<br>(3,0)\u306e\u6210\u5206\u306f0\u3067\u3059\u3002(4,1)\u306e\u6210\u5206\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br>\u307e\u305f\u6210\u5206\u306f\u8981\u7d20\u3068\u3082\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<h2 id=\"i-12\">\u307e\u3068\u3081<\/h2>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u3001NumPy\u3067\u3088\u304f\u4f7f\u3046\u30e1\u30bd\u30c3\u30c9\u3084\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u306a\u3069\u306eNumPy\u306e\u57fa\u672c\u7684\u306a\u5185\u5bb9\u3092\u5b66\u3073\u307e\u3057\u305f\u3002<br>NumPy\u306f\u975e\u5e38\u306b\u4fbf\u5229\u304b\u3064\u3088\u304f\u5229\u7528\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u306e\u3067\u3001\u4f7f\u3044\u3053\u306a\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/aiacademy.jp\/bootcamp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-1024x341.png\" alt=\"\" class=\"wp-image-691\" srcset=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-1024x341.png 1024w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-300x100.png 300w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-768x256.png 768w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-940x313.png 940w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 NumPy\u3068\u306f \u306a\u305cNumPy\u3092\u5b66\u3076\u306e\u304b NumPy\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb NumPy\u3092\u4f7f\u7528\u3059\u308b \u914d\u5217(\u30a2\u30ec\u30a4)\u3092\u4f5c\u308b NumPy\u914d\u5217\u306e\u5f62\u72b6\u3092\u8abf\u3079\u308b \u914d\u5217\u306e\u751f\u6210 arange() \u914d\u5217\u64cd\u4f5c \u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8 \u591a\u6b21\u5143\u914d\u5217\u306e\u8a08 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":484,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,105],"tags":[],"class_list":{"0":"post-148","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python","8":"category-105"},"_links":{"self":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=148"}],"version-history":[{"count":5,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":4832,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/148\/revisions\/4832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/media\/484"}],"wp:attachment":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}