{"id":4999,"date":"2020-11-16T17:16:38","date_gmt":"2020-11-16T11:46:38","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=4999"},"modified":"2021-07-10T13:15:10","modified_gmt":"2021-07-10T07:45:10","slug":"python-vector","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/python-vector\/","title":{"rendered":"Python Vector With Various Operations Using Numpy"},"content":{"rendered":"\n<p>Python Vector, in layman&#8217;s language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and arrays is that. Unlike typical arrays, the vectors&#8217; data, and size are mutable. The vectors are also known as dynamic arrays.  Arrays and vectors are both basic data structures. The Vectors in Python comprising of numerous values in an organized manner.<\/p>\n\n\n\n<p>Python Vectors can be represented as:  <strong><em>v = [v1, v2, v3]<\/em><\/strong>.<br>Here v is a single-dimensional array having v1, v2, and v3 as ordinary numeral values.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Python_Vector_operations_using_NumPy_library\" >Python Vector operations using NumPy library:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Importing_NumPy_for_Python_Vector\" >Importing NumPy for Python Vector:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Vector_definition_in_python\" >Vector definition in python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Addition_of_vectors_in_Python\" >Addition of vectors in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Subtraction_of_vectors_in_Python\" >Subtraction of vectors in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Python_Vector_Dot_Product\" >Python Vector Dot Product:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Python_Vector_Cross_Product\" >Python Vector Cross Product:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Multiplication_of_a_Python_Vector_with_a_scalar\" >Multiplication of a Python Vector with a scalar:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Unit_Vector_of_Python_Vector\" >Unit Vector of Python Vector:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Must_Read\" >Must Read<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#Conclusion\" >Conclusion:<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-python-vector-operations-using-numpy-library\"><span class=\"ez-toc-section\" id=\"Python_Vector_operations_using_NumPy_library\"><\/span>Python Vector operations using NumPy library:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Single dimensional arrays are created in python by importing an array module. The multi-dimensional arrays cannot be created with the array module implementation. Vectors are created using the import <a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.array.html#numpy-array\">array class<\/a>. However, various operations are performed over vectors. Some of the operations include basic addition, <a href=\"http:\/\/www.pythonpool.com\/numpy-subtract\/\" target=\"_blank\" rel=\"noreferrer noopener\">subtraction<\/a>, multiplication, division. Some other operations include dot product and cross product of two vectors.<\/p>\n\n\n\n<p>You can also do operations on those who are not available in the array module. So, to implement multidimensional arrays ( single-dimensional arrays can also be created). For doing the faster operations on arrays and vectors, one such library containing all such functions is NumPy.  For instance, the NumPy module is thus imported into the python program for the required vectors&#8217; operations. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-importing-numpy-for-python-vector\"><span class=\"ez-toc-section\" id=\"Importing_NumPy_for_Python_Vector\"><\/span>Importing NumPy for Python Vector:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If we write import NumPy in our programs while using any python 3 versions. It shows an error. The NumPy package is not available by default. We need to install it manually. Python has an amazing tool called the pip (pip install packages). Moreover, the pip package has many such packages that are not present in python by default. You can install a lot of packages using the pip. Pip can be used to install the Numpy package and to run the python program error-free.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"239\" height=\"211\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/2.png\" alt=\"Vector components - magnitude and direction while searching for 'Python Vector'\" class=\"wp-image-5013\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-vector-definition-in-python\"><span class=\"ez-toc-section\" id=\"Vector_definition_in_python\"><\/span>Vector definition in python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We can define a vector in python as a NumPy array. For example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n#create a vector\nfrom numpy import array\nvec = array(&#x5B;1, 5, 6])\nprint(vec)\n<\/pre><\/div>\n\n\n<p>This example defines a vector of three elements and print them as:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;1, 5, 6]\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-addition-of-vectors-in-python\"><span class=\"ez-toc-section\" id=\"Addition_of_vectors_in_Python\"><\/span>Addition of vectors in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# addition of vectors\nfrom numpy import array\nx = array(&#x5B;1, 5, 6])\nprint(x)\ny = array(&#x5B;1, 5, 6])\nprint(y)\nz = x + y\nprint(z)\n<\/pre><\/div>\n\n\n<p>The output of the above python code for addition of two numbers is :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;1, 5, 6]\n&#x5B;1, 5, 6]\n&#x5B;2, 10, 12]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>Fistly, the final vector&#8217;s length is the same as the two parents&#8217; vectors. Each element of the new vector is the sum of the two vectors. NumPy allows compact and direct addition of two vectors. Without using the NumPy array, the code becomes hectic. Also, it would require the addition of each element individually. And then creating a new vector to store them. The other basic arithmetic operations like subtraction, multiplication, and division. Similarly, using the NumPy package these operations can be done in a similar way. Just the operator changes depending upon the operation.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"443\" height=\"187\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/1.png\" alt=\"Vector addition of two vectors\n\" class=\"wp-image-5014\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/1.png 443w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/1-300x127.png 300w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-subtraction-of-vectors-in-python\"><span class=\"ez-toc-section\" id=\"Subtraction_of_vectors_in_Python\"><\/span>Subtraction of vectors in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# addition of vectors\nfrom numpy import array\nx = array(&#x5B;1, 5, 6])\nprint(x)\ny = array(&#x5B;1, 4, 6])\nprint(y)\nz = x - y\nprint(z)\n<\/pre><\/div>\n\n\n<p>The output of the above python code for subtraction of two numbers is :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;1 5 6]\n&#x5B;1 4 6]\n&#x5B;0 1 0]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-1\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>We start by importing the Numpy module and initializing two arrays. Both of these arrays are three dimensional and have different reference points. You can easily subtract these two arrays using the &#8216;-&#8216; operator. In addition operation, the minus operator also performs in the same way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-vector-dot-product\"><span class=\"ez-toc-section\" id=\"Python_Vector_Dot_Product\"><\/span>Python Vector Dot Product:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n#vector dot product\nfrom numpy import array\nx = array(&#x5B;1, 2, 3])\nprint(x)\ny = array(&#x5B;1, 2, 5])\nprint(y)\nz = x.dot(y)\nprint(z)\n<\/pre><\/div>\n\n\n<p>The output of the dot product of the above two vectors is:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;1, 2, 3]\n&#x5B;1, 2, 5]\n20\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-2\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>Dot product calculates the sum of the two vectors&#8217; multiplied elements. Dot Product returns a scalar number as a result. The dot product is useful in calculating the projection of vectors. Dot product in Python also determines orthogonality and vector decompositions. The dot product is calculated using the dot function, due to the numpy package, i.e., .dot().<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-vector-cross-product\"><span class=\"ez-toc-section\" id=\"Python_Vector_Cross_Product\"><\/span>Python Vector Cross Product:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Python Vector Cross product works in the same way as the normal cross product. A cross vector is defined as a vector that is perpendicular to these two vectors with a magnitude equal to the area of the parallelogram spanned by both vectors. As of now, the vector object honest has a cross multiplication method like that of a dot. We&#8217;ll have to use np.cross() to find the cross product.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n#vector cross product\nfrom numpy import array\nimport numpy as np\nx = array(&#x5B;1, 2, 3])\nprint(x)\ny = array(&#x5B;1, 2, 5])\nprint(y)\nz = np.cross(x, y)\nprint(z)\n<\/pre><\/div>\n\n\n<p>The output of the dot product of the above two vectors is:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;1 2 3]\n&#x5B;1 2 5]\n&#x5B; 4 -2  0]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-3\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>Cross Product returns a vector that is perpendicular to both vectors. Firstly, we start by importing the numpy module and array class from it. Nextly, we initialize two arrays with different values. As a cross product of the same vector gives a zero vector, we have to use two different vectors. At last, np.cross() returns the cross multiplied vector of two NumPy arrays.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-multiplication-of-a-python-vector-with-a-scalar\"><span class=\"ez-toc-section\" id=\"Multiplication_of_a_Python_Vector_with_a_scalar\"><\/span>Multiplication of a Python Vector with a scalar:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# scalar vector multiplication\nfrom numpy import array\na = array(&#x5B;1, 2, 3])\nprint(a)\nb = 2.0\nprint(s)\nc = s * a\nprint(c)\n<\/pre><\/div>\n\n\n<p><strong>The output of the above vector scalar multiplication in python is :<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;1, 2, 3]\n2.0\n&#x5B;2.0, 4.0, 6.0]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-4\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>Vector scalar multiplication in python is a straightforward thing to understand. It is just the multiplication of all the vectors&#8217; elements. Ordinary numbers are used for the multiplication of vector elements, i.e., a scalar. The returning that multiplied vector as the new vector output.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-unit-vector-of-python-vector\"><span class=\"ez-toc-section\" id=\"Unit_Vector_of_Python_Vector\"><\/span>Unit Vector of Python Vector:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Unit Vectors are the vectors with the same directions as a normal vector but their magnitude equals 1. These vectors are amazingly important for carrying out multiple operations in 3d space. As there is no available method to convert the vector into normal form, we&#8217;ll have to use the sum() method of the numpy array.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n#unit vector product\nfrom numpy import array\nx = array(&#x5B;1, 2, 3])\nx_hat = x \/ (x**2).sum()**0.5\nprint(x)\n<\/pre><\/div>\n\n\n<p><strong>The output of the above vector scalar multiplication in python is :<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#x5B;0.26726124 0.53452248 0.80178373]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-5\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>Firstly, we import the necessary classes and initialize a dummy array x. This array has a magnitude not equal to 1. To convert it to 1, we first find its magnitude and divide it. (x**2).sum()**0.5 is used to find the magnitude of vector x.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.pythonpool.com\/python-super\/\">Introduction to Python Super With Examples<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-help-function\/\">Python Help Function<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-sys-exit\/\">Why is Python sys.exit better than other exit functions?<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-bitstring\/\">Python Bitstring: Classes and Other Examples | Module<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Python vector is <strong>simply a one-dimensional array<\/strong>. We<strong> can perform all operations using lists or importing an array module. But installing and importing the NumPy package made all the vector operations easier and faster. Vectors are plotted and drawn using arrows by importing matplotlib.pyplot. <\/strong>To draw vectors with arrows in python, the function used is matplotlib.pyplot.quiver(). However, the quiver function takes four arguments. Out of which, the first two arguments are the data about where the arrows will be. And the other two take the data of the ending point of the arrows.<\/p>\n\n\n\n<p>Still have any doubts or questions do let me know in the comment section below. I will try to help you as soon as possible.<\/p>\n\n\n\n<p><strong><em>Happy Pythoning!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Vector, in layman&#8217;s language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and arrays is that. Unlike typical &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Vector With Various Operations Using Numpy\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-vector\/#more-4999\" aria-label=\"More on Python Vector With Various Operations Using Numpy\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":5371,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1495,15],"tags":[2497,2498,2501,2502,2503,2500,2499],"class_list":["post-4999","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-numpy","category-tutorials","tag-normalize-vector-python","tag-python-vector","tag-support-vector-machine-python","tag-support-vector-machines-python","tag-support-vector-regression-python","tag-vector-in-python","tag-vector-python","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Vector With Various Operations Using Numpy - Python Pool<\/title>\n<meta name=\"description\" content=\"Python Vector, in layman&#039;s language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and array\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/python-vector\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Vector With Various Operations Using Numpy\" \/>\n<meta property=\"og:description\" content=\"Python Vector, in layman&#039;s language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and arrays is that.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-vector\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-16T11:46:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-10T07:45:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Python Pool\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Python Pool\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/\"},\"author\":{\"name\":\"Python Pool\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998\"},\"headline\":\"Python Vector With Various Operations Using Numpy\",\"datePublished\":\"2020-11-16T11:46:38+00:00\",\"dateModified\":\"2021-07-10T07:45:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/\"},\"wordCount\":1075,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png\",\"keywords\":[\"normalize vector python\",\"python vector\",\"support vector machine python\",\"support vector machines python\",\"support vector regression python\",\"vector in python\",\"vector python\"],\"articleSection\":[\"Numpy\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-vector\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-vector\/\",\"name\":\"Python Vector With Various Operations Using Numpy - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png\",\"datePublished\":\"2020-11-16T11:46:38+00:00\",\"dateModified\":\"2021-07-10T07:45:10+00:00\",\"description\":\"Python Vector, in layman's language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and array\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-vector\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png\",\"width\":1350,\"height\":650,\"caption\":\"Python Vector\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-vector\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Vector With Various Operations Using Numpy\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998\",\"name\":\"Python Pool\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"caption\":\"Python Pool\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Vector With Various Operations Using Numpy - Python Pool","description":"Python Vector, in layman's language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and array","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pythonpool.com\/python-vector\/","og_locale":"en_US","og_type":"article","og_title":"Python Vector With Various Operations Using Numpy","og_description":"Python Vector, in layman's language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and arrays is that.","og_url":"https:\/\/www.pythonpool.com\/python-vector\/","og_site_name":"Python Pool","article_published_time":"2020-11-16T11:46:38+00:00","article_modified_time":"2021-07-10T07:45:10+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png","type":"image\/png"}],"author":"Python Pool","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Python Pool","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/python-vector\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/python-vector\/"},"author":{"name":"Python Pool","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998"},"headline":"Python Vector With Various Operations Using Numpy","datePublished":"2020-11-16T11:46:38+00:00","dateModified":"2021-07-10T07:45:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-vector\/"},"wordCount":1075,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png","keywords":["normalize vector python","python vector","support vector machine python","support vector machines python","support vector regression python","vector in python","vector python"],"articleSection":["Numpy","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/python-vector\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/python-vector\/","url":"https:\/\/www.pythonpool.com\/python-vector\/","name":"Python Vector With Various Operations Using Numpy - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png","datePublished":"2020-11-16T11:46:38+00:00","dateModified":"2021-07-10T07:45:10+00:00","description":"Python Vector, in layman's language, is nothing but a one-dimensional array of numbers. The only difference between python vectors and array","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/python-vector\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/python-vector\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/python-vector\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-13.png","width":1350,"height":650,"caption":"Python Vector"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/python-vector\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python Vector With Various Operations Using Numpy"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998","name":"Python Pool","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","caption":"Python Pool"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/4999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=4999"}],"version-history":[{"count":38,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/4999\/revisions"}],"predecessor-version":[{"id":14514,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/4999\/revisions\/14514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/5371"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=4999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=4999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=4999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}