{"id":129,"date":"2026-03-02T14:23:46","date_gmt":"2026-03-02T09:23:46","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=129"},"modified":"2026-03-16T18:28:20","modified_gmt":"2026-03-16T13:28:20","slug":"arrays","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/arrays\/","title":{"rendered":"Arrays"},"content":{"rendered":"\n<p>An <strong>array<\/strong> is a data structure used to store multiple values in a single variable.<br>In Data Analytics, arrays are mainly used through the <strong>NumPy<\/strong> library because they are faster and more efficient than normal Python lists.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an Array?<\/h2>\n\n\n\n<p>An array is a collection of elements stored in a structured format (usually in rows and columns).<\/p>\n\n\n\n<p>Example of a simple list:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">numbers = [1, 2, 3, 4]<\/pre>\n\n\n\n<p>Example of a NumPy array:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import numpy as nparr = np.array([1, 2, 3, 4])<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use NumPy Arrays Instead of Lists?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Faster performance<\/li>\n\n\n\n<li>Less memory usage<\/li>\n\n\n\n<li>Supports mathematical operations directly<\/li>\n\n\n\n<li>Works efficiently with large datasets<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Types of Arrays<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1D Array (Single Dimension)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr = np.array([10, 20, 30, 40])<\/pre>\n\n\n\n<p>Shape: (4,)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2D Array (Matrix)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr2 = np.array([[1, 2, 3],<br>                 [4, 5, 6]])<\/pre>\n\n\n\n<p>Shape: (2, 3)<\/p>\n\n\n\n<p>2 rows and 3 columns<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3D Array<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr3 = np.array([<br>    [[1, 2], [3, 4]],<br>    [[5, 6], [7, 8]]<br>])<\/pre>\n\n\n\n<p>Used in advanced data and image processing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Array Properties<\/h2>\n\n\n\n<p>Check shape:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr.shape<\/pre>\n\n\n\n<p>Check number of dimensions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr.ndim<\/pre>\n\n\n\n<p>Check size (total elements):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr.size<\/pre>\n\n\n\n<p>Check data type:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr.dtype<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Accessing Elements<\/h2>\n\n\n\n<p>Access by index:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr[0]      # First element<br>arr2[1, 2]  # Row 2, Column 3<\/pre>\n\n\n\n<p>Slicing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr[1:3]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Array Operations<\/h2>\n\n\n\n<p>Addition:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr + 5<\/pre>\n\n\n\n<p>Multiplication:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr * 2<\/pre>\n\n\n\n<p>Array + Array:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr + arr<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Special Array Creation Functions<\/h2>\n\n\n\n<p>Zeros:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.zeros((2, 3))<\/pre>\n\n\n\n<p>Ones:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.ones((3, 3))<\/pre>\n\n\n\n<p>Range:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.arange(0, 10)<\/pre>\n\n\n\n<p>Random numbers:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.random.rand(3, 3)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Arrays Matter in Data Analytics<\/h2>\n\n\n\n<p>Arrays allow you to:<\/p>\n\n\n\n<p>Perform fast calculations<br>Handle structured data<br>Apply mathematical models<br>Work with large datasets efficiently<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Takeaway<\/h2>\n\n\n\n<p>Arrays are the backbone of numerical computing in Python.<br>Understanding NumPy arrays is essential for Data Analytics, Machine Learning, and Scientific Computing.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FOR DATA ANALYTICS (PYDA) > NumPy > Arrays<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773667558036\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":66,"template":"","class_list":["post-129","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arrays - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn NumPy arrays in Python for Data Analytics. Create, access, and perform fast calculations on 1D, 2D, and 3D arrays\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/arrays\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arrays - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn NumPy arrays in Python for Data Analytics. Create, access, and perform fast calculations on 1D, 2D, and 3D arrays\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/arrays\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T13:28:20+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/arrays\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/arrays\\\/\",\"name\":\"Arrays - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-02T09:23:46+00:00\",\"dateModified\":\"2026-03-16T13:28:20+00:00\",\"description\":\"Learn NumPy arrays in Python for Data Analytics. Create, access, and perform fast calculations on 1D, 2D, and 3D arrays\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/arrays\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/arrays\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/arrays\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FOR DATA ANALYTICS (PYDA) > NumPy > Arrays\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arrays - One Language. Endless Possibilities","description":"Learn NumPy arrays in Python for Data Analytics. Create, access, and perform fast calculations on 1D, 2D, and 3D arrays","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:\/\/gigz.pk\/python\/lesson\/arrays\/","og_locale":"en_US","og_type":"article","og_title":"Arrays - One Language. Endless Possibilities","og_description":"Learn NumPy arrays in Python for Data Analytics. Create, access, and perform fast calculations on 1D, 2D, and 3D arrays","og_url":"https:\/\/gigz.pk\/python\/lesson\/arrays\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-16T13:28:20+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/arrays\/","url":"https:\/\/gigz.pk\/python\/lesson\/arrays\/","name":"Arrays - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-02T09:23:46+00:00","dateModified":"2026-03-16T13:28:20+00:00","description":"Learn NumPy arrays in Python for Data Analytics. Create, access, and perform fast calculations on 1D, 2D, and 3D arrays","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/arrays\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/arrays\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/arrays\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FOR DATA ANALYTICS (PYDA) > NumPy > Arrays"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}