{"id":209,"date":"2014-08-29T09:18:01","date_gmt":"2014-08-29T00:18:01","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=209"},"modified":"2019-10-19T08:53:51","modified_gmt":"2019-10-18T23:53:51","slug":"blog50","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog50\/","title":{"rendered":"(50) numpy\u914d\u5217\u306e\u90e8\u5206\u7d71\u8a08\u8a08\u7b97"},"content":{"rendered":"<p>numpy\u914d\u5217\u306b\u5bfe\u3057\u3066\u90e8\u5206\u7684\u306b\u5e73\u5747\u5024\u3084\u6a19\u6e96\u504f\u5dee\u3092\u6c42\u3081\u305f\u3044\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b 10\u884c8\u5217\u306e\u6574\u6570\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(10,8) * 10).astype(np.int32)\r\n&gt;&gt;&gt; a\r\narray([[2, 7, 7, 9, 9, 4, 4, 3],\r\n       [8, 1, 4, 5, 2, 2, 0, 9],\r\n       [5, 6, 3, 4, 3, 4, 2, 5],\r\n       [0, 0, 7, 9, 3, 8, 6, 5],\r\n       [0, 0, 8, 0, 5, 8, 9, 3],\r\n       [9, 9, 3, 3, 3, 8, 9, 3],\r\n       [4, 3, 9, 7, 9, 2, 6, 2],\r\n       [2, 9, 9, 5, 0, 7, 6, 0],\r\n       [8, 2, 2, 1, 5, 1, 7, 8],\r\n       [7, 0, 4, 6, 8, 9, 0, 5]], dtype=int32)\r\n<\/pre>\n<p>a[2][3]\u3092\u8d77\u70b9\u306b 3\u884c2\u5217\u306e\u7bc4\u56f2\u306b\u5bfe\u3057\u3066\u7d71\u8a08\u8a08\u7b97\u3057\u305f\u3044\u3002<br \/>\n\u898b\u8f9b\u3044\u306e\u3067\u53d6\u308a\u51fa\u3057\u3066\u307f\u308b\u3002\u5207\u308a\u51fa\u3057\u305f\u3082\u306e\u3092\u5225\u5909\u6570\u306b\u4ee3\u5165\u3057\u305f\u65b9\u304c\u6271\u3044\u3084\u3059\u3044\u304b&#8230;<\/p>\n<pre>&gt;&gt;&gt; a[2:2+3, 3:3+2]\r\narray([[4, 3],\r\n       [9, 3],\r\n       [0, 5]], dtype=int32)\r\n<\/pre>\n<p><span class=\"my_fc_deeppinkB\">sum<\/span>\u3067\u7dcf\u548c\u3092\u6c42\u3081\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; a[2:2+3, 3:3+2].<span class=\"my_fc_deeppinkB\">sum<\/span>()\r\n24\r\n<\/pre>\n<p><span class=\"my_fc_deeppinkB\">mean<\/span>\u3067\u5e73\u5747\u5024\u3092\u6c42\u3081\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; a[2:2+3, 3:3+2].<span class=\"my_fc_deeppinkB\">mean<\/span>()\r\n4.0\r\n<\/pre>\n<p><span class=\"my_fc_deeppinkB\">std<\/span>\u3067\u6a19\u6e96\u504f\u5dee\u3092\u6c42\u3081\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; a[2:2+3, 3:3+2].<span class=\"my_fc_deeppinkB\">std<\/span>()\r\n2.70801280154532\r\n<\/pre>\n<p><span class=\"my_fc_deeppinkB\">max<\/span>\u3067\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; a[2:2+3, 3:3+2].<span class=\"my_fc_deeppinkB\">max<\/span>()\r\n9\r\n<\/pre>\n<p><span class=\"my_fc_deeppinkB\">min<\/span>\u3067\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\u3002<\/p>\n<pre>&gt;&gt;&gt; a[2:2+3, 3:3+2].<span class=\"my_fc_deeppinkB\">min<\/span>()\r\n0\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>numpy\u914d\u5217\u306b\u5bfe\u3057\u3066\u90e8\u5206\u7684\u306b\u5e73\u5747\u5024\u3084\u6a19\u6e96\u504f\u5dee\u3092\u6c42\u3081\u305f\u3044\u3002 \u4ee5\u4e0b\u306e\u3088\u3046\u306b 10\u884c8\u5217\u306e\u6574\u6570\u914d\u5217 a\u3092\u4f5c\u308b\u3002 &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; a = (np.ran\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog50\/\">\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-209","post","type-post","status-publish","format-standard","hentry","category-numpy"],"views":9315,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/209","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=209"}],"version-history":[{"count":6,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":2657,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/209\/revisions\/2657"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}