<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sanaipei</title>
    <description>The latest articles on DEV Community by sanaipei (@lesanaipei).</description>
    <link>https://dev.to/lesanaipei</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4186678%2F14f830eb-4b78-4fe4-af0b-edb7a4a27f30.png</url>
      <title>DEV Community: sanaipei</title>
      <link>https://dev.to/lesanaipei</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lesanaipei"/>
    <language>en</language>
    <item>
      <title>Getting Started with NumPy: Understanding Numerical Computing in Python</title>
      <dc:creator>sanaipei</dc:creator>
      <pubDate>Sun, 06 Dec 2026 09:40:16 +0000</pubDate>
      <link>https://dev.to/lesanaipei/-getting-started-with-numpy-understanding-numerical-computing-in-python-d01</link>
      <guid>https://dev.to/lesanaipei/-getting-started-with-numpy-understanding-numerical-computing-in-python-d01</guid>
      <description>&lt;p&gt;&lt;strong&gt;By Lenapunya Sanaipei| Pastoralist in Tech&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Introduction
&lt;/h4&gt;

&lt;p&gt;As I continue exploring the Python data science ecosystem, one of the first libraries I want to revisit is NumPy.&lt;/p&gt;

&lt;p&gt;NumPy is one of the foundational libraries in Python's scientific computing ecosystem. It provides tools for working with numerical data, performing mathematical operations and handling multidimensional arrays.&lt;/p&gt;

&lt;p&gt;If you've worked with Python lists before, you might wonder why we need another way of storing collections of numbers.&lt;/p&gt;

&lt;p&gt;Python already allows us to store information in lists, perform calculations and manipulate data.&lt;/p&gt;

&lt;p&gt;So, what makes NumPy different?&lt;/p&gt;

&lt;p&gt;That's what we'll explore in this article.&lt;/p&gt;

&lt;p&gt;We'll start with the basics, understand how NumPy arrays work, explore their dimensions and properties, and perform some practical numerical operations.&lt;/p&gt;

&lt;p&gt;I'll also include Python code that you can follow along with in Google Colab.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. What is NumPy?
&lt;/h4&gt;

&lt;p&gt;NumPy stands for &lt;strong&gt;Numerical Python&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is an open-source Python library designed for numerical computing.&lt;/p&gt;

&lt;p&gt;It provides a multidimensional array object called &lt;code&gt;ndarray&lt;/code&gt;, alongside functions for performing mathematical operations, linear algebra, Fourier transforms and other numerical computations.&lt;/p&gt;

&lt;p&gt;NumPy was created by Travis Oliphant and released in 2005.&lt;/p&gt;

&lt;p&gt;One of its main strengths is its ability to perform efficient operations on large collections of numerical data.&lt;/p&gt;

&lt;h5&gt;
  
  
  Why do we need NumPy?
&lt;/h5&gt;

&lt;p&gt;Python has built-in data structures such as lists and tuples that allow us to store collections of information.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;incomes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a perfectly valid Python list.&lt;/p&gt;

&lt;p&gt;We can calculate its average using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;average_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incomes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incomes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;average_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, when working with large numerical datasets, we often need more specialised operations.&lt;/p&gt;

&lt;p&gt;This is where NumPy becomes useful.&lt;/p&gt;

&lt;p&gt;NumPy provides efficient array operations, mathematical functions and numerical tools that are particularly useful in data science.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Python Lists vs NumPy Arrays
&lt;/h4&gt;

&lt;p&gt;Let's compare the two.&lt;/p&gt;

&lt;p&gt;A Python list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;incomes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A NumPy array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;incomes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both store our income values.&lt;/p&gt;

&lt;p&gt;However, they behave differently when performing numerical operations.&lt;/p&gt;

&lt;p&gt;Consider this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10, 20, 30, 10, 20, 30]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because multiplying a Python list by an integer repeats the list.&lt;/p&gt;

&lt;p&gt;Now let's try NumPy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[20 40 60]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time, every element has been multiplied by two.&lt;/p&gt;

&lt;p&gt;This is one of the important differences between Python lists and NumPy arrays.&lt;/p&gt;

&lt;h5&gt;
  
  
  Why is NumPy generally faster?
&lt;/h5&gt;

&lt;p&gt;NumPy arrays are designed for numerical computation.&lt;/p&gt;

&lt;p&gt;They generally store elements in contiguous memory blocks, making numerical data access more efficient.&lt;/p&gt;

&lt;p&gt;They also use optimised operations implemented largely in compiled languages such as C.&lt;/p&gt;

&lt;p&gt;Another important concept is &lt;strong&gt;vectorisation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Vectorisation allows us to perform operations across entire arrays without writing explicit Python loops for each element.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;incomes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;increased_incomes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;incomes&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1.10&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;increased_incomes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[11000. 16500. 22000.]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have increased every income value by 10%.&lt;/p&gt;

&lt;p&gt;This is particularly useful when working with large numerical datasets.&lt;/p&gt;

&lt;p&gt;The exact performance advantage depends on the operation, data size and implementation. NumPy is not automatically faster for every task.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Understanding NumPy Arrays
&lt;/h4&gt;

&lt;p&gt;The central data structure in NumPy is called an &lt;code&gt;ndarray&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The name stands for N-dimensional array.&lt;/p&gt;

&lt;p&gt;An array is a collection of elements organised into one or more dimensions.&lt;/p&gt;

&lt;p&gt;Let's understand these dimensions.&lt;/p&gt;

&lt;h5&gt;
  
  
  3.1 Zero-dimensional array (0D)
&lt;/h5&gt;

&lt;p&gt;A zero-dimensional array contains a single value.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can inspect its dimensions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why is it zero-dimensional?&lt;/p&gt;

&lt;p&gt;Because the array contains one value without any row or column structure.&lt;/p&gt;

&lt;p&gt;Think of it as a single numerical observation.&lt;/p&gt;

&lt;h5&gt;
  
  
  3.2 One-dimensional array (1D)
&lt;/h5&gt;

&lt;p&gt;A one-dimensional array contains elements arranged along one axis.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;incomes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incomes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10000 15000 20000 25000]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This resembles a single row of numbers.&lt;/p&gt;

&lt;p&gt;We can inspect its dimension:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incomes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A practical example could be a collection of household income observations.&lt;/p&gt;

&lt;h5&gt;
  
  
  3.3 Two-dimensional array (2D)
&lt;/h5&gt;

&lt;p&gt;A two-dimensional array has two axes, commonly represented as rows and columns.&lt;/p&gt;

&lt;p&gt;Imagine we have collected monthly income observations from three households.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;monthly_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;21000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;monthly_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[[10000 12000 15000]
 [20000 22000 25000]
 [15000 18000 21000]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can represent this as a table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Household&lt;/th&gt;
&lt;th&gt;January&lt;/th&gt;
&lt;th&gt;February&lt;/th&gt;
&lt;th&gt;March&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;12,000&lt;/td&gt;
&lt;td&gt;15,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;20,000&lt;/td&gt;
&lt;td&gt;22,000&lt;/td&gt;
&lt;td&gt;25,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;15,000&lt;/td&gt;
&lt;td&gt;18,000&lt;/td&gt;
&lt;td&gt;21,000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Check its dimension:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;monthly_income&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a 2D array because it has rows and columns.&lt;/p&gt;

&lt;h5&gt;
  
  
  3.4 Three-dimensional array (3D)
&lt;/h5&gt;

&lt;p&gt;A three-dimensional array introduces another axis.&lt;/p&gt;

&lt;p&gt;Imagine we have income observations for three households across two different years, with three monthly observations per year.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;yearly_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;11000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;21000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;23000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;26000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;21000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;16000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yearly_income&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We now have three dimensions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Household.&lt;/li&gt;
&lt;li&gt;Year.&lt;/li&gt;
&lt;li&gt;Month.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This illustrates how NumPy can organise more complex numerical data.&lt;/p&gt;

&lt;p&gt;Higher-dimensional arrays are also important in image processing, scientific computing and machine learning.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Creating NumPy Arrays
&lt;/h4&gt;

&lt;p&gt;Now that we understand what arrays are, let's learn how to create them.&lt;/p&gt;

&lt;p&gt;First, we import NumPy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;import&lt;/code&gt; statement loads the library.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;as np&lt;/code&gt; part gives NumPy a shorter name.&lt;/p&gt;

&lt;p&gt;This is the standard convention used throughout the Python data science ecosystem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating an array using np.array()
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;numbers&lt;/code&gt; is the variable holding our array.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;np.array()&lt;/code&gt; is the NumPy function that creates the array.&lt;/li&gt;
&lt;li&gt;The values inside the square brackets are our original data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can also create arrays from nested Python lists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a two-dimensional array.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Understanding NumPy Array Properties
&lt;/h4&gt;

&lt;p&gt;Creating an array is only the beginning.&lt;/p&gt;

&lt;p&gt;When working with datasets, we need to understand their structure.&lt;/p&gt;

&lt;p&gt;NumPy provides several properties that help us inspect an array.&lt;/p&gt;

&lt;p&gt;Let's use this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sales&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;12000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;22000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;14000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  5.1 ndim - Number of dimensions
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ndim&lt;/code&gt; property tells us how many dimensions an array has.&lt;/p&gt;

&lt;p&gt;In this case, we have a two-dimensional array.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.2 shape - Structure of the array
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(3, 3)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result tells us that the array has three rows and three columns.&lt;/p&gt;

&lt;p&gt;For a two-dimensional array, the shape is represented as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(rows, columns)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.3 size - Total number of elements
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are nine numerical observations in the array.&lt;/p&gt;

&lt;h5&gt;
  
  
  5.4 dtype - Data type of elements
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output might be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells us the data type NumPy uses to represent the array's elements.&lt;/p&gt;

&lt;p&gt;Depending on the environment, you may see a different integer type.&lt;/p&gt;

&lt;p&gt;Understanding data types becomes important when preparing datasets for mathematical operations and machine learning.&lt;/p&gt;

&lt;h5&gt;
  
  
  Putting everything together
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Dimensions:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Shape:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Total elements:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Data type:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives us a quick overview of the array.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Performing Mathematical Operations with NumPy
&lt;/h4&gt;

&lt;p&gt;NumPy is particularly useful when we need to perform numerical operations.&lt;/p&gt;

&lt;p&gt;Let's create a simple dataset inspired by household income observations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;household_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Calculating the total
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Calculating the average
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Finding the minimum value
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Finding the maximum value
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Calculating the median
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These functions allow us to perform common descriptive calculations.&lt;/p&gt;

&lt;p&gt;However, there is an important distinction between calculating a statistic and interpreting it.&lt;/p&gt;

&lt;p&gt;For example, the average household income does not necessarily tell us whether most households earn around that amount.&lt;/p&gt;

&lt;p&gt;Income data can be skewed by a small number of households with particularly high incomes.&lt;/p&gt;

&lt;p&gt;This is why we need to understand distributions and other statistical measures, not just calculate averages.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Practical Application: Working with Household Data
&lt;/h4&gt;

&lt;p&gt;Let's bring everything together.&lt;/p&gt;

&lt;p&gt;Imagine we are conducting a hypothetical research exercise involving household income observations in an Ilchamus community setting.&lt;/p&gt;

&lt;p&gt;Our objective is to explore a small collection of household income figures.&lt;/p&gt;

&lt;p&gt;For this exercise, we'll use entirely illustrative numbers. They are not actual Ilchamus household income statistics.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="c1"&gt;# Illustrative household income observations&lt;/span&gt;
&lt;span class="n"&gt;household_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="mi"&gt;12000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;18000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;22000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;17000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;28000&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Basic analysis&lt;/span&gt;
&lt;span class="n"&gt;total_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;average_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;median_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;minimum_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;maximum_income&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;household_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Display the results&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Total:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Average:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;average_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Median:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;median_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Minimum:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minimum_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Maximum:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maximum_income&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What have we done?&lt;/p&gt;

&lt;p&gt;We created an array containing household income observations and used NumPy to calculate descriptive statistics.&lt;/p&gt;

&lt;p&gt;But let's think beyond the code.&lt;/p&gt;

&lt;p&gt;What does the average actually tell us?&lt;/p&gt;

&lt;p&gt;Is the median different from the average?&lt;/p&gt;

&lt;p&gt;Are the observations representative of the wider community?&lt;/p&gt;

&lt;p&gt;What other variables would we need to understand household income patterns?&lt;/p&gt;

&lt;p&gt;For instance, we might need information about income sources, livestock ownership, agricultural production, household size, location and the period during which income was recorded.&lt;/p&gt;

&lt;p&gt;These questions remind us that numerical computations are only one part of data analysis.&lt;/p&gt;

&lt;p&gt;The quality of our conclusions depends on the quality of the data, the research design and how we interpret the results.&lt;/p&gt;

&lt;h4&gt;
  
  
  8. Why NumPy Matters in Data Science
&lt;/h4&gt;

&lt;p&gt;NumPy is important because it provides numerical computing capabilities that are used throughout the Python ecosystem.&lt;/p&gt;

&lt;p&gt;Several popular libraries build on or integrate with NumPy.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pandas:&lt;/strong&gt; Uses NumPy extensively in its numerical data structures and operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Matplotlib:&lt;/strong&gt; Works with NumPy arrays when creating visualisations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SciPy:&lt;/strong&gt; Builds on NumPy for scientific computing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scikit-learn:&lt;/strong&gt; Uses NumPy arrays extensively in its machine learning workflows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding NumPy therefore makes it easier to understand what happens when working with other data science libraries.&lt;/p&gt;

&lt;h4&gt;
  
  
  Conclusion
&lt;/h4&gt;

&lt;p&gt;NumPy is much more than a library for creating arrays.&lt;/p&gt;

&lt;p&gt;It provides a foundation for numerical computing in Python and helps us work efficiently with numerical data.&lt;/p&gt;

&lt;p&gt;In this article, we've explored what NumPy is, why it is useful, how its arrays work, the different dimensions and some of the properties and mathematical operations we can perform.&lt;/p&gt;

&lt;p&gt;The next step is to take these concepts into a practical Google Colab notebook and experiment with arrays ourselves.&lt;/p&gt;

&lt;p&gt;As I continue this journey from Data Analytics towards Data Science, I want to keep reminding myself that knowing the functions is only part of the process.&lt;/p&gt;

&lt;p&gt;Understanding the data, asking the right questions and knowing why we are performing an operation are equally important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The goal is not to become someone who can simply execute Python code. The goal is to become someone who understands the problem, knows which tools to use and can turn data into meaningful information.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; From Data Analytics to Data Science with Python&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Previous article:&lt;/strong&gt; From Data Analytics to Data Science: Exploring the Python Data Science Ecosystem&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Next practical step:&lt;/strong&gt; NumPy Arrays in Google Colab&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; Sanaipei Lenapunya&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Identity:&lt;/strong&gt; Pastoralist in Tech&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://sanaipei.me" rel="noopener noreferrer"&gt;https://sanaipei.me&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>From Data Analytics to Data Science: Exploring the Python Data Science Ecosystem</title>
      <dc:creator>sanaipei</dc:creator>
      <pubDate>Sun, 06 Dec 2026 08:35:45 +0000</pubDate>
      <link>https://dev.to/lesanaipei/from-data-analytics-to-data-science-exploring-the-python-data-science-ecosystem-3288</link>
      <guid>https://dev.to/lesanaipei/from-data-analytics-to-data-science-exploring-the-python-data-science-ecosystem-3288</guid>
      <description>&lt;p&gt;&lt;strong&gt;By Lenapunya Sanaipei | Pastoralist in Tech&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Introduction
&lt;/h4&gt;

&lt;p&gt;Data has always fascinated me, not just because of the numbers, but because of the stories, questions and possibilities hidden within it.&lt;/p&gt;

&lt;p&gt;My journey into technology started with an interest in data analytics. Over time, I developed an appreciation for working with data, understanding patterns, cleaning datasets, conducting exploratory data analysis and communicating findings that can support decision-making.&lt;/p&gt;

&lt;p&gt;Python has been one of the tools I've particularly enjoyed working with.&lt;/p&gt;

&lt;p&gt;However, as I continue growing in the data space, I find myself increasingly interested in exploring the broader field of Data Science, particularly statistics, predictive modelling and machine learning.&lt;/p&gt;

&lt;p&gt;This is not necessarily about abandoning data analytics. It is about building on that foundation, strengthening my understanding and exploring what more we can do with data.&lt;/p&gt;

&lt;p&gt;I am documenting this journey as I revisit familiar concepts, learn new ones and experiment with Python's data science ecosystem.&lt;/p&gt;

&lt;p&gt;And as someone who identifies as a &lt;strong&gt;Pastoralist in Tech&lt;/strong&gt;, I am particularly interested in exploring how data and technology can help us understand questions affecting communities, including pastoralist communities such as my own, the Ilchamus of Kenya.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. What is Data Science?
&lt;/h4&gt;

&lt;p&gt;Data Science is an interdisciplinary field that combines programming, statistics, mathematics, analytical thinking and domain knowledge to extract meaningful insights from data.&lt;/p&gt;

&lt;p&gt;It involves more than simply collecting data or creating visualisations.&lt;/p&gt;

&lt;p&gt;Depending on the problem, data science can involve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Collecting data from different sources.&lt;/li&gt;
&lt;li&gt;Cleaning and preparing datasets.&lt;/li&gt;
&lt;li&gt;Exploring and understanding patterns.&lt;/li&gt;
&lt;li&gt;Applying statistical methods.&lt;/li&gt;
&lt;li&gt;Building predictive models.&lt;/li&gt;
&lt;li&gt;Evaluating machine learning algorithms.&lt;/li&gt;
&lt;li&gt;Communicating findings.&lt;/li&gt;
&lt;li&gt;Supporting informed decisions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One way I like to think about Data Science is through the relationship between three important areas:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Analytics:&lt;/strong&gt; Helps us understand data, identify patterns, investigate what happened and explore why it happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Statistics:&lt;/strong&gt; Helps us understand distributions, relationships, uncertainty, probability and whether observations provide sufficient evidence for conclusions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Machine Learning:&lt;/strong&gt; Allows computers to learn patterns from data and use those patterns to make predictions or support decisions.&lt;/p&gt;

&lt;p&gt;These areas overlap, and Data Science brings them together alongside programming and domain expertise.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Data Science is More Than Knowing the Tools
&lt;/h4&gt;

&lt;p&gt;This is probably one of the most important things I want to emphasise throughout this learning journey.&lt;/p&gt;

&lt;p&gt;You can learn Python, NumPy, Pandas, Seaborn, Scikit-learn and many other libraries.&lt;/p&gt;

&lt;p&gt;But knowing how to import a library, execute a function or train a machine learning model does not automatically make you a good data scientist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The tools are enablers. Critical thinking comes first.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before opening a notebook or writing a single line of code, we should understand the problem we are trying to solve.&lt;/p&gt;

&lt;p&gt;Consider an example.&lt;/p&gt;

&lt;p&gt;Suppose we want to investigate household income patterns in parts of the Ilchamus community around Lake Baringo, Kenya.&lt;/p&gt;

&lt;p&gt;Instead of immediately opening Python, we should begin by asking questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What exactly do we want to understand about household income?&lt;/li&gt;
&lt;li&gt;Are we interested in income sources, income distribution or changes over time?&lt;/li&gt;
&lt;li&gt;What information would help us answer these questions?&lt;/li&gt;
&lt;li&gt;Where can we obtain reliable data?&lt;/li&gt;
&lt;li&gt;Who collected the data, and for what purpose?&lt;/li&gt;
&lt;li&gt;Are there missing values, inconsistencies or potential biases?&lt;/li&gt;
&lt;li&gt;Which analytical methods are appropriate?&lt;/li&gt;
&lt;li&gt;Would statistical analysis be sufficient, or is predictive modelling necessary?&lt;/li&gt;
&lt;li&gt;How do we communicate the findings responsibly?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Only after understanding these questions can we start deciding which tools to use.&lt;/p&gt;

&lt;p&gt;For example, if our objective is to understand the distribution of household income, descriptive statistics and visualisations might be sufficient.&lt;/p&gt;

&lt;p&gt;If we want to investigate whether certain household characteristics are associated with income differences, we might explore statistical methods.&lt;/p&gt;

&lt;p&gt;If we have a well-defined predictive objective and suitable historical data, we could consider machine learning.&lt;/p&gt;

&lt;p&gt;The important thing is that the problem determines the approach, not the availability of a particular library.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Why Python for Data Science?
&lt;/h4&gt;

&lt;p&gt;Python is a general-purpose programming language that has become widely used in data science, scientific computing, automation and machine learning.&lt;/p&gt;

&lt;p&gt;One of the reasons I enjoy Python is its readability.&lt;/p&gt;

&lt;p&gt;Its syntax makes it relatively easy to express instructions, experiment with ideas and build practical applications.&lt;/p&gt;

&lt;p&gt;Python also has a large ecosystem of libraries that support different stages of working with data.&lt;/p&gt;

&lt;p&gt;Instead of implementing every mathematical operation, statistical method or machine learning algorithm from scratch, we can use existing libraries.&lt;/p&gt;

&lt;p&gt;However, using a library should not replace understanding what happens behind the scenes.&lt;/p&gt;

&lt;p&gt;We should understand the purpose of a function, the assumptions it makes, the inputs it expects and how to interpret its output.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Exploring the Python Data Science Libraries
&lt;/h4&gt;

&lt;p&gt;Let's look at some of the libraries we will explore throughout this series.&lt;/p&gt;

&lt;h5&gt;
  
  
  4.1 NumPy - Numerical Computing
&lt;/h5&gt;

&lt;p&gt;NumPy stands for Numerical Python.&lt;/p&gt;

&lt;p&gt;It is a fundamental Python library for numerical computing and working with multidimensional arrays.&lt;/p&gt;

&lt;p&gt;Its main object is called an ndarray (N-dimensional array).&lt;/p&gt;

&lt;p&gt;NumPy provides functionality for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating and manipulating arrays.&lt;/li&gt;
&lt;li&gt;Performing mathematical operations.&lt;/li&gt;
&lt;li&gt;Working with matrices.&lt;/li&gt;
&lt;li&gt;Linear algebra.&lt;/li&gt;
&lt;li&gt;Numerical computations.&lt;/li&gt;
&lt;li&gt;Random number generation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why do we need it?&lt;/p&gt;

&lt;p&gt;Imagine we have collected household income figures and want to calculate the average income, identify the minimum and maximum values or perform calculations across thousands of observations.&lt;/p&gt;

&lt;p&gt;NumPy provides efficient operations for working with numerical data.&lt;/p&gt;

&lt;p&gt;We will explore array creation, dimensions, indexing, slicing, reshaping and vectorised operations.&lt;/p&gt;

&lt;h5&gt;
  
  
  4.2 Pandas - Data Manipulation and Analysis
&lt;/h5&gt;

&lt;p&gt;Pandas is a Python library designed for working with structured and tabular data.&lt;/p&gt;

&lt;p&gt;Its most familiar data structure is the DataFrame.&lt;/p&gt;

&lt;p&gt;Think of a DataFrame as a table containing rows and columns.&lt;/p&gt;

&lt;p&gt;For example, a household dataset might contain:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Household&lt;/th&gt;
&lt;th&gt;Location&lt;/th&gt;
&lt;th&gt;Income&lt;/th&gt;
&lt;th&gt;Livestock&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;H001&lt;/td&gt;
&lt;td&gt;Location A&lt;/td&gt;
&lt;td&gt;15,000&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;H002&lt;/td&gt;
&lt;td&gt;Location B&lt;/td&gt;
&lt;td&gt;22,000&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;H003&lt;/td&gt;
&lt;td&gt;Location A&lt;/td&gt;
&lt;td&gt;18,000&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With Pandas, we can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read CSV and Excel files.&lt;/li&gt;
&lt;li&gt;Inspect datasets.&lt;/li&gt;
&lt;li&gt;Handle missing values.&lt;/li&gt;
&lt;li&gt;Remove duplicates.&lt;/li&gt;
&lt;li&gt;Filter records.&lt;/li&gt;
&lt;li&gt;Group and aggregate data.&lt;/li&gt;
&lt;li&gt;Merge datasets.&lt;/li&gt;
&lt;li&gt;Conduct exploratory data analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pandas will be particularly useful when we start working with complete datasets rather than individual numerical arrays.&lt;/p&gt;

&lt;h5&gt;
  
  
  4.3 Matplotlib - Data Visualisation
&lt;/h5&gt;

&lt;p&gt;Matplotlib is a Python library for creating visualisations.&lt;/p&gt;

&lt;p&gt;It allows us to communicate patterns and relationships through charts and figures.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bar charts.&lt;/li&gt;
&lt;li&gt;Line graphs.&lt;/li&gt;
&lt;li&gt;Histograms.&lt;/li&gt;
&lt;li&gt;Scatter plots.&lt;/li&gt;
&lt;li&gt;Box plots.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For instance, we might want to visualise changes in rainfall over several years or compare household income across different locations.&lt;/p&gt;

&lt;p&gt;Visualisation is not simply about making charts look attractive.&lt;/p&gt;

&lt;p&gt;It is about choosing a visual representation that helps answer a particular question.&lt;/p&gt;

&lt;h5&gt;
  
  
  4.4 Seaborn - Statistical Data Visualisation
&lt;/h5&gt;

&lt;p&gt;Seaborn is built on top of Matplotlib and provides a higher-level interface for statistical visualisation.&lt;/p&gt;

&lt;p&gt;It makes it easier to explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data distributions.&lt;/li&gt;
&lt;li&gt;Correlations.&lt;/li&gt;
&lt;li&gt;Relationships between variables.&lt;/li&gt;
&lt;li&gt;Categorical comparisons.&lt;/li&gt;
&lt;li&gt;Statistical patterns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, we could investigate the relationship between household income and livestock ownership.&lt;/p&gt;

&lt;p&gt;A scatter plot might help us explore whether the two variables appear to be associated.&lt;/p&gt;

&lt;p&gt;However, a visible relationship does not automatically establish causation.&lt;/p&gt;

&lt;p&gt;That is another important part of thinking critically about data.&lt;/p&gt;

&lt;h5&gt;
  
  
  4.5 SciPy - Scientific Computing
&lt;/h5&gt;

&lt;p&gt;SciPy builds on NumPy and provides additional functionality for scientific and technical computing.&lt;/p&gt;

&lt;p&gt;It includes tools for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Statistical tests.&lt;/li&gt;
&lt;li&gt;Optimisation.&lt;/li&gt;
&lt;li&gt;Numerical integration.&lt;/li&gt;
&lt;li&gt;Scientific calculations.&lt;/li&gt;
&lt;li&gt;Signal processing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will explore it when we get deeper into statistical analysis and scientific methods.&lt;/p&gt;

&lt;h5&gt;
  
  
  4.6 Scikit-learn - Machine Learning
&lt;/h5&gt;

&lt;p&gt;Scikit-learn is one of the most widely used Python libraries for traditional machine learning.&lt;/p&gt;

&lt;p&gt;It provides tools for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data preprocessing.&lt;/li&gt;
&lt;li&gt;Classification.&lt;/li&gt;
&lt;li&gt;Regression.&lt;/li&gt;
&lt;li&gt;Clustering.&lt;/li&gt;
&lt;li&gt;Model selection.&lt;/li&gt;
&lt;li&gt;Model evaluation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, imagine we have historical agricultural production data and want to investigate whether we can predict future production using available variables.&lt;/p&gt;

&lt;p&gt;We might explore regression algorithms.&lt;/p&gt;

&lt;p&gt;Alternatively, if we want to classify records into predefined categories, classification algorithms might be appropriate.&lt;/p&gt;

&lt;p&gt;But remember: we should not select an algorithm before understanding the objective, the dataset and the problem.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. How Do These Libraries Work Together?
&lt;/h4&gt;

&lt;p&gt;Let's use our household income investigation as an example.&lt;/p&gt;

&lt;p&gt;Suppose we have collected household information for a research project.&lt;/p&gt;

&lt;p&gt;Our workflow might look something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;NumPy:&lt;/strong&gt; Perform numerical operations and work with arrays.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pandas:&lt;/strong&gt; Load, clean and organise the collected data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Matplotlib:&lt;/strong&gt; Create visualisations to explore the dataset.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seaborn:&lt;/strong&gt; Investigate distributions and relationships between variables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SciPy:&lt;/strong&gt; Apply appropriate statistical tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scikit-learn:&lt;/strong&gt; Build and evaluate predictive models if the research objective requires them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These libraries do not operate independently of one another. They can be used together within the same Python workflow.&lt;/p&gt;

&lt;p&gt;Also, not every project requires all of them.&lt;/p&gt;

&lt;p&gt;Sometimes a well-conducted descriptive analysis is enough to answer the research question.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Connecting Data Science to Pastoralist Communities
&lt;/h4&gt;

&lt;p&gt;This is an area I am particularly interested in exploring.&lt;/p&gt;

&lt;p&gt;Growing up with a connection to the Ilchamus community has shaped some of the questions I find meaningful.&lt;/p&gt;

&lt;p&gt;The Ilchamus are a Maa-speaking community associated with the Lake Baringo region of Kenya. Their history and livelihoods include pastoralism, agriculture and fishing.&lt;/p&gt;

&lt;p&gt;This provides an interesting context for exploring how data science can be applied to questions involving livelihoods, environmental conditions, livestock, agriculture and community development.&lt;/p&gt;

&lt;p&gt;For example, we could investigate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How do household income sources vary?&lt;/li&gt;
&lt;li&gt;How do rainfall patterns relate to agricultural production?&lt;/li&gt;
&lt;li&gt;What patterns can we observe in livestock ownership?&lt;/li&gt;
&lt;li&gt;How do market prices affect livestock-related income?&lt;/li&gt;
&lt;li&gt;What can historical environmental data tell us about changing conditions?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are potential research questions, not conclusions about the community.&lt;/p&gt;

&lt;p&gt;Any real investigation would require appropriately collected and verified data, community participation and respect for the people whose information is being used.&lt;/p&gt;

&lt;p&gt;I also believe communities should not only be subjects of data collection. They should have a voice in deciding what information is collected, how it is interpreted and how the resulting knowledge is used.&lt;/p&gt;

&lt;p&gt;That is part of why I find the intersection of data science, indigenous knowledge and data governance so interesting.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. What Are We Going to Learn?
&lt;/h4&gt;

&lt;p&gt;Throughout this series, I will be revisiting and exploring the following areas:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;What we'll explore&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;Programming foundations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NumPy&lt;/td&gt;
&lt;td&gt;Numerical computing and arrays&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pandas&lt;/td&gt;
&lt;td&gt;Data manipulation and cleaning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matplotlib&lt;/td&gt;
&lt;td&gt;Data visualisation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seaborn&lt;/td&gt;
&lt;td&gt;Statistical visualisation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Statistics&lt;/td&gt;
&lt;td&gt;Probability, distributions and inference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scikit-learn&lt;/td&gt;
&lt;td&gt;Machine learning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Algorithms&lt;/td&gt;
&lt;td&gt;Regression, classification and clustering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Practical projects&lt;/td&gt;
&lt;td&gt;Applying the concepts to real-world problems&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We'll use Python and Google Colab for practical experimentation.&lt;/p&gt;

&lt;p&gt;The goal is not simply to finish tutorials. It is to understand what we are doing, why we are doing it and when to apply what we learn.&lt;/p&gt;

&lt;h4&gt;
  
  
  Conclusion
&lt;/h4&gt;

&lt;p&gt;Moving from Data Analytics towards Data Science is an opportunity to deepen my understanding of data, strengthen my statistical thinking and explore machine learning.&lt;/p&gt;

&lt;p&gt;I am approaching this journey with curiosity, a willingness to revisit the fundamentals and an interest in connecting technology to real-world problems.&lt;/p&gt;

&lt;p&gt;As a Pastoralist in Tech, I also hope to explore how these skills can contribute to conversations about pastoralist communities, indigenous knowledge and the responsible use of data.&lt;/p&gt;

&lt;p&gt;I am documenting the journey as I go, learning in public and sharing practical experiments along the way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools are enablers. Understanding the problem, asking the right questions and thinking critically about the data will always come first.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's see where Python takes us.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; From Data Analytics to Data Science with Python&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Next article:&lt;/strong&gt; Getting Started with NumPy: Understanding Numerical Computing in Python&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; Lenapunya Sanaipei&lt;br&gt;
&lt;strong&gt;Personal website:&lt;/strong&gt; &lt;a href="https://sanaipei.me" rel="noopener noreferrer"&gt;https://sanaipei.me&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
