{"id":206,"date":"2014-08-29T08:43:01","date_gmt":"2014-08-28T23:43:01","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=206"},"modified":"2019-10-19T08:51:41","modified_gmt":"2019-10-18T23:51:41","slug":"blog49","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog49\/","title":{"rendered":"(49) numpy\u914d\u5217\u306e\u90e8\u5206\u4ee3\u5165"},"content":{"rendered":"<p>\u4f8b\u3068\u3057\u3066 8\u884c5\u5217\u306e\u914d\u5217 a\u3092\u4f5c\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; import numpy as np\r\n&gt;&gt;&gt; a = np.random.rand(8,5)\r\n&gt;&gt;&gt; a\r\narray([[ 0.59477343,  0.39696101,  0.8635444 ,  0.57730748,  0.80778975],\r\n       [ 0.36723965,  0.48813453,  0.53213475,  0.0682938 ,  0.23692774],\r\n       [ 0.82790539,  0.02619104,  0.7563847 ,  0.10553861,  0.59796693],\r\n       [ 0.62885835,  0.61025432,  0.60352469,  0.09148856,  0.55585131],\r\n       [ 0.54324068,  0.61347011,  0.6137894 ,  0.8560153 ,  0.39223471],\r\n       [ 0.28993199,  0.37723578,  0.65900017,  0.60465485,  0.56363825],\r\n       [ 0.00705464,  0.58109945,  0.79664211,  0.92434556,  0.01637478],\r\n       [ 0.79555517,  0.61280461,  0.32642076,  0.70221643,  0.17151009]])\r\n<\/pre>\n<p>\u3053\u308c\u306b\u90e8\u5206\u4ee3\u5165\u3059\u308b 3\u884c2\u5217\u306e\u914d\u5217 b\u3092\u4f5c\u308b\u3002<br \/>\n\u4ee3\u5165\u7d50\u679c\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u6574\u6570\u3068\u3059\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; b=(np.random.rand(3,2) * 10).astype(np.int32).astype(np.float32)\r\n&gt;&gt;&gt; b\r\narray([[ 2.,  7.],\r\n       [ 4.,  6.],\r\n       [ 7.,  7.]], dtype=float32)\r\n<\/pre>\n<p>a[2][2]\u3092\u8d77\u70b9\u306b b\u3092\u4ee3\u5165\u3059\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; sb = b.shape\r\n&gt;&gt;&gt; sb\r\n(3, 2)\r\n&gt;&gt;&gt; a[2:2+sb[0], 2:2+sb[1]] = b\r\n&gt;&gt;&gt; a\r\narray([[ 0.59477343,  0.39696101,  0.8635444 ,  0.57730748,  0.80778975],\r\n       [ 0.36723965,  0.48813453,  0.53213475,  0.0682938 ,  0.23692774],\r\n       [ 0.82790539,  0.02619104,  <span class=\"my_fc_deeppinkB\">2.        ,  7.<\/span>        ,  0.59796693],\r\n       [ 0.62885835,  0.61025432,  <span class=\"my_fc_deeppinkB\">4.        ,  6.<\/span>        ,  0.55585131],\r\n       [ 0.54324068,  0.61347011,  <span class=\"my_fc_deeppinkB\">7.        ,  7.<\/span>        ,  0.39223471],\r\n       [ 0.28993199,  0.37723578,  0.65900017,  0.60465485,  0.56363825],\r\n       [ 0.00705464,  0.58109945,  0.79664211,  0.92434556,  0.01637478],\r\n       [ 0.79555517,  0.61280461,  0.32642076,  0.70221643,  0.17151009]])\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>\u4f8b\u3068\u3057\u3066 8\u884c5\u5217\u306e\u914d\u5217 a\u3092\u4f5c\u308b\u3002 &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; a = np.random.rand(8,5) &gt;&gt;&gt; a array([\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog49\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-206","post","type-post","status-publish","format-standard","hentry","category-numpy"],"views":9642,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/comments?post=206"}],"version-history":[{"count":8,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":2655,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/206\/revisions\/2655"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}