{"id":1028,"date":"2021-07-09T12:56:03","date_gmt":"2021-07-09T12:56:03","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=1028"},"modified":"2021-07-09T12:56:03","modified_gmt":"2021-07-09T12:56:03","slug":"numpy-chast-2-bazovye-operaczii-nad-massivami","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/en\/numpy-chast-2-bazovye-operaczii-nad-massivami\/","title":{"rendered":"NumPy, \u0447\u0430\u0441\u0442\u044c 2: \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u042f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043f\u043e\u0441\u043e\u0431\u0438\u0435\u043c \u043f\u043e python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 NumPy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412&nbsp;<a href=\"https:\/\/pythonworld.ru\/numpy\/1.html\" target=\"_blank\" rel=\"noreferrer noopener\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>&nbsp;\u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438 \u0438\u0445 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430, \u0435\u0441\u043b\u0438 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043d\u0430\u0434 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e. \u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430.>>><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><strong>>>> import<\/strong> <strong>numpy<\/strong> <strong>as<\/strong> <strong>np<\/strong>\n<strong>>>> <\/strong>a = np.array([20, 30, 40, 50])\n<strong>>>> <\/strong>b = np.arange(4)\n<strong>>>> <\/strong>a + b\narray([20, 31, 42, 53])\n<strong>>>> <\/strong>a - b\narray([20, 29, 38, 47])\n<strong>>>> <\/strong>a * b\narray([  0,  30,  80, 150])\n<strong>>>> <\/strong>a \/ b  <em># \u041f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0430 0 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f inf (\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c)<\/em>\narray([         inf,  30.        ,  20.        ,  16.66666667])\n&lt;string>:1: RuntimeWarning: divide by zero encountered in true_divide\n<strong>>>> <\/strong>a ** b\narray([     1,     30,   1600, 125000])\n<strong>>>> <\/strong>a % b  <em># \u041f\u0440\u0438 \u0432\u0437\u044f\u0442\u0438\u0438 \u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 0 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f 0<\/em>\n&lt;string>:1: RuntimeWarning: divide by zero encountered in remainder\narray([0, 0, 0, 2])<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><strong>>>> <\/strong>c = np.array([[1, 2, 3], [4, 5, 6]])\n<strong>>>> <\/strong>d = np.array([[1, 2], [3, 4], [5, 6]])\n<strong>>>> <\/strong>c + d\nTraceback (most recent call last):\n  File \"&lt;input>\", line 1, in &lt;module>\nValueError: operands could not be broadcast together with shapes (2,3) (3,2)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0438 \u0447\u0438\u0441\u043b\u043e\u043c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f (\u0438\u043b\u0438 \u0447\u0442\u043e \u0432\u044b \u0442\u0430\u043c \u0434\u0435\u043b\u0430\u0435\u0442\u0435) \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>&gt;&gt;&gt; <\/strong>a + 1\narray([21, 31, 41, 51])\n<strong>&gt;&gt;&gt; <\/strong>a ** 3\narray([  8000,  27000,  64000, 125000])\n<strong>&gt;&gt;&gt; <\/strong>a &lt; 35  <em># \u0418 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c<\/em>\narray([ True,  True, False, False], dtype=bool)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u042f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043f\u043e\u0441\u043e\u0431\u0438\u0435\u043c \u043f\u043e python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 NumPy. \u0412&nbsp;\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438&nbsp;\u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438 \u0438\u0445 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[77],"tags":[],"class_list":["post-1028","page","type-page","status-publish","hentry","category-numpy"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/1028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/comments?post=1028"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/1028\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/media?parent=1028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/categories?post=1028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/tags?post=1028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}