<?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: Daniel Mutwiri Mbabu</title>
    <description>The latest articles on DEV Community by Daniel Mutwiri Mbabu (@daniel_mutwirimbabu).</description>
    <link>https://dev.to/daniel_mutwirimbabu</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%2F2745709%2F9f5f0b94-b3d9-4656-971f-349c9d997da1.jpeg</url>
      <title>DEV Community: Daniel Mutwiri Mbabu</title>
      <link>https://dev.to/daniel_mutwirimbabu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daniel_mutwirimbabu"/>
    <language>en</language>
    <item>
      <title>UV, PIP, Pandas, and NumPy for Data Analysts are just tools; thinking is the real Job.</title>
      <dc:creator>Daniel Mutwiri Mbabu</dc:creator>
      <pubDate>Wed, 21 Oct 2026 12:34:30 +0000</pubDate>
      <link>https://dev.to/daniel_mutwirimbabu/uv-pip-pandas-and-numpy-for-data-analysts-are-just-tools-thinking-is-the-real-job-1clo</link>
      <guid>https://dev.to/daniel_mutwirimbabu/uv-pip-pandas-and-numpy-for-data-analysts-are-just-tools-thinking-is-the-real-job-1clo</guid>
      <description>&lt;p&gt;Today, we dive into the world of data analysis using Python. Our journey starts with setting up a Python virtual environment, managing packages, and transforming raw data into meaningful insights through analytical thinking which is what actually an analyst is paid for. &lt;/p&gt;

&lt;p&gt;From the premise of the topic, you might wonder, if we are using Python, then what are UVs, PIPs, Pandas, and NumPy in our Heading? And I will simply answer you that these are tools built for Python that will help us reach our destination. UV and PIP help us manage our Python environment and tools, while NumPy and pandas help us turn data into something useful.&lt;/p&gt;

&lt;h1&gt;
  
  
  Every Data Journey starts with a solid plan
&lt;/h1&gt;

&lt;p&gt;Imagine you have just landed a data analytics project. Your assignment is to analyse sales across several branches, identify the best-performing products, uncover revenue trends, and present recommendations to management. You have Python installed on your computer. You open VS Code, create a project folder, and write your first line of code.&lt;/p&gt;

&lt;p&gt;Then reality hits.&lt;/p&gt;

&lt;p&gt;Your code cannot find a library. You install a package, but another project stops working. You import a dataset, only to discover missing values, inconsistent records, and numbers that do not add up. Eventually, you realise that analysing data is not simply about writing Python code. It is about building a reliable environment and using the right tools to manipulate information.&lt;/p&gt;

&lt;p&gt;This is where four important tools enter the story: &lt;strong&gt;UV, PIP, NumPy, and Pandas.&lt;/strong&gt; Each plays a different role:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UV:&lt;/strong&gt; A fast Python project and package manager that can manage environments, dependencies, and Python versions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PIP:&lt;/strong&gt; Python's traditional package installer, used to install and manage Python packages. (It's slow, so we mostly prefer UV)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NumPy:&lt;/strong&gt; A library for fast numerical computing, multidimensional arrays, and mathematical operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pandas:&lt;/strong&gt; A library for working with structured data, particularly tables containing rows and columns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, your plan is in complete shambles. This is because before the tools comes the understanding of the problem, the accurate problem framing process, understanding the objectives of the analysis and what success would look like and only then can you start using the tools. How can you drive without knowing where you're going?&lt;/p&gt;

&lt;p&gt;Now that we have established the journey plan, let's look at the tools. UV or PIP helps us prepare, organise, pack, and equip ourselves. NumPy and Pandas help us arrive at our destination (the vision we have established) as the tools for cleaning and analysing our data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding PIP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is PIP?
&lt;/h3&gt;

&lt;p&gt;PIP stands for &lt;em&gt;Pip Installs Packages&lt;/em&gt;. It is the standard package installer commonly used in Python projects. Data professionals often need additional libraries not built into Python for specialised tasks. PIP makes this possible by helping us to download and install. Some of these packages are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;What it helps you do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;NumPy&lt;/td&gt;
&lt;td&gt;Numerical computation and array operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pandas&lt;/td&gt;
&lt;td&gt;Data manipulation and analysis&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;Requests&lt;/td&gt;
&lt;td&gt;Make HTTP requests&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;SQLAlchemy&lt;/td&gt;
&lt;td&gt;Work with databases&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Installing a package using PIP
&lt;/h3&gt;

&lt;p&gt;To install pandas and NumPy using PIP,&lt;/p&gt;

&lt;p&gt;Open your terminal (PowerShell) and execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip install pandas numpy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl8q31vp3jpol8clw305r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl8q31vp3jpol8clw305r.png" alt=" " width="799" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's break this down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;python&lt;/code&gt; runs the Python interpreter.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-m pip&lt;/code&gt; runs pip as a Python module, helping ensure you use the pip associated with that interpreter.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;install&lt;/code&gt; tells pip to install packages.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pandas numpy&lt;/code&gt; identifies the two packages you want.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why use &lt;code&gt;python -m pip&lt;/code&gt; instead of simply &lt;code&gt;pip&lt;/code&gt;? On systems with multiple Python installations, the standalone &lt;code&gt;pip&lt;/code&gt; command may point to a different interpreter. Using &lt;code&gt;python -m pip&lt;/code&gt; makes the relationship more explicit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating an isolated or virtual environment
&lt;/h3&gt;

&lt;p&gt;Imagine project A requires pandas version 2.2, while project B requires a different version. Installing everything globally can create dependency conflicts. A virtual environment provides an isolated location for a project's Python packages. To create one:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffhg4i21zpw5bse229ii1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffhg4i21zpw5bse229ii1.png" alt=" " width="670" height="101"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv .venv  #Creates the virtual environment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.\.venv\Scripts\Activate.ps1 #Activates it on Windows using PowerShell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once activated, install the packages inside the environment using the installation code we used above. Now, your project has its own package environment, reducing interference from unrelated projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Just a few essential PIP operations I think you should know
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip --version  #Checking your pip version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip list  #Checking the List of installed packages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip show pandas #Inspecting a particular package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip install --upgrade pandas  #Upgrading a package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip uninstall pandas  #Uninstalling a package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip check  #Checking for dependency problems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When should you use PIP?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You need a simple way to install Python packages.&lt;/li&gt;
&lt;li&gt;You are working with an existing project that uses &lt;code&gt;requirements.txt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But what if you want a tool that brings project setup, Python version management, virtual environments, dependency resolution, and package installation together? Then PIP no longer cuts it. That brings us to UV.&lt;/p&gt;

&lt;h2&gt;
  
  
  UV
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is UV?
&lt;/h3&gt;

&lt;p&gt;UV is a modern Python package and project manager. It is designed to be fast and to simplify several aspects of Python development. While pip primarily installs packages, UV offers a broader project-management workflow.&lt;/p&gt;

&lt;p&gt;UV supports workflows that use &lt;code&gt;pyproject.toml&lt;/code&gt; and &lt;code&gt;uv.lock&lt;/code&gt;, while also offering commands for pip-compatible workflows.&lt;/p&gt;

&lt;p&gt;UV can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install and manage Python versions.&lt;/li&gt;
&lt;li&gt;Create and manage virtual environments.&lt;/li&gt;
&lt;li&gt;Add and remove project dependencies.&lt;/li&gt;
&lt;li&gt;Resolve and lock dependencies.&lt;/li&gt;
&lt;li&gt;Run commands within a project's environment.&lt;/li&gt;
&lt;li&gt;Install packages quickly, using caching and other optimisations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Installing UV
&lt;/h3&gt;

&lt;p&gt;On Windows, one installation option is (in PowerShell):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;winget install --id
  astral-sh.uv -e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, follow the official installation instructions at:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.astral.sh/uv/getting-started/installation/" rel="noopener noreferrer"&gt;https://docs.astral.sh/uv/getting-started/installation/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installation, verify it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuoyo68ojc2re1gln7omh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuoyo68ojc2re1gln7omh.png" alt=" " width="718" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating your first UV project
&lt;/h3&gt;

&lt;p&gt;Going back to our sales analytics project.&lt;/p&gt;

&lt;p&gt;Let's create a new project by initializing UV in the project folder:&lt;/p&gt;

&lt;p&gt;Move into the directory (in the terminal):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd sales-analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv init sales-analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UV creates a project structure like the one below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sales-analytics/
├── .python-version
├── .venv/
├── main.py
├── pyproject.toml
└── uv.lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what the files mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.python-version&lt;/code&gt; specifies the project's intended Python version when generated.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.venv/&lt;/code&gt; contains the virtual environment created for the project.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;main.py&lt;/code&gt; contains your Python code.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pyproject.toml&lt;/code&gt; records project configuration and declared dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uv.lock&lt;/code&gt; records the resolved dependency versions for reproducible installations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The lockfile is particularly important when you collaborate with others or move a project between development and production.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing packages with UV
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv add pandas numpy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UV processes this and makes the packages available to the project environment.&lt;/p&gt;

&lt;p&gt;To ensure the project environment is prepared, uses the created environment to execute your script; use this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv run main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It helps you work without repeatedly activating the virtual environment manually.&lt;/p&gt;

&lt;h3&gt;
  
  
  Just a few essential UV Commands I think you should know
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv --version  #Checking the installed UV version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv python list #Listing Python installations managed by UV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv python install 3.12 #Installing a particular Python version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv python pin 3.12 #Pinning the project's Python version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv add matplotlib #Adding a dependency
uv remove matplotlib #Removing a dependency
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv run main.py #Running a Python script in the project environment
uv run python -c "import pandas; print(pandas.__version__)" #Running a Python command directly
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uv sync  #Synchronizing the environment with the project lockfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that our vehicle is ready for the journey, we can start our journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pandas
&lt;/h2&gt;

&lt;p&gt;Pandas is a Python library built for data manipulation and analysis. It provides convenient structures for working with labelled, tabular data.&lt;/p&gt;

&lt;p&gt;Pandas is the data analyst's workstation. It helps you load data, inspect its structure, clean inconsistencies, filter records, combine datasets, calculate metrics, and prepare information for reporting.&lt;/p&gt;

&lt;p&gt;Pandas has two important data structures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Series:&lt;/strong&gt; which is a one-dimensional labelled array.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DataFrame:&lt;/strong&gt; a two-dimensional table with labelled rows and columns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Importing Pandas&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Note, we use the conventional alias &lt;code&gt;pd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsom08rfyq3s1oijnfc2l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsom08rfyq3s1oijnfc2l.png" alt=" " width="342" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirming the environment variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkm6wmdsc2odp7bvre8jc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkm6wmdsc2odp7bvre8jc.png" alt=" " width="423" height="32"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating and checking a Pandas Series&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sales = pd.Series([1200, 1500, 1800, 1300, 2200])

print(sales)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating a DataFrame&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = {
    "BookingID": ["BK-2023-00001", "BK-2023-00002", "BK-2023-00003"],
    "BookingDate": ["2023-01-01", "2023-01-02", "2023-01-01"],
    "CustomerID": ["C01696", "C01796", "C01546"]
}

df = pd.DataFrame(data)

print(df)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inspecting your data before analysis (EDA)
&lt;/h3&gt;

&lt;p&gt;Before any analysis, we must use clean data, but before knowing the data is clean, we must inspect it through exploratory data analysis.&lt;/p&gt;

&lt;p&gt;Here are some of the commands we use to inspect our data with&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(df.head())  #To check the first 5 rows of our data&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsfj2jw5unjqieh88kslj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsfj2jw5unjqieh88kslj.png" alt=" " width="753" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(df.tail())  #To check the last 5 rows of the data&lt;/code&gt;&lt;br&gt;
&lt;code&gt;print(df.shape) # Checking number of rows and columns&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F03tdfpzevp2vif0czu4i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F03tdfpzevp2vif0czu4i.png" alt=" " width="560" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(df.columns) # checking column names&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff7ps94yqak3zto97akdv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff7ps94yqak3zto97akdv.png" alt=" " width="758" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(df.dtypes) # checking data types&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgg6fskq78nkdexf2fsfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgg6fskq78nkdexf2fsfr.png" alt=" " width="327" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(df.info()) # checking the summary of our dataset&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjguyur8tn8rgmwwvm2f7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjguyur8tn8rgmwwvm2f7.png" alt=" " width="550" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(df.describe()) # checking the description of the dataset&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmbvhli3pvziluyle7x9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmbvhli3pvziluyle7x9i.png" alt=" " width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Reading data from files
&lt;/h2&gt;

&lt;p&gt;Most often than not, we will be using external data sources rather than manually creating dataframes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; For large datasets, always consider reading only the necessary columns or processing the data in chunks rather than loading everything into memory at once.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For a CSV file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.read_csv("sales.csv")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For an Excel workbook:&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;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_excel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sales.xlsx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a JSON file:&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;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sales.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a database,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.read_sql(
    "SELECT * FROM sales",
    con=engine #"engine" represents an already configured SQLAlchemy database engine. It must exist before the query can run.
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selecting rows and columns with &lt;code&gt;loc&lt;/code&gt; and &lt;code&gt;iloc&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;loc&lt;/code&gt; selects by label.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.DataFrame({
    "product": ["Laptop", "Phone", "Tablet"],
    "sales": [400000, 360000, 200000]
}, index=["A", "B", "C"])

print(df.loc["B"])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns the row labelled &lt;code&gt;B&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can also select a particular column:&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;B&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sales&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;iloc&lt;/code&gt; selects by index position.&lt;/strong&gt; - I like to call it index location&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(df.iloc[1])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns the second row because Python uses zero-based indexing.&lt;/p&gt;

&lt;p&gt;To select the second row and second column:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(df.iloc[1, 1])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;loc&lt;/code&gt; uses row and column labels.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;iloc&lt;/code&gt; uses integer positions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Creating new columns
&lt;/h3&gt;

&lt;p&gt;Suppose our sales dataset contains the number of units sold and the unit price, but not total revenue.&lt;/p&gt;

&lt;p&gt;We can calculate it for every line in a new column by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df["revenue"] = df["units_sold"] * df["unit_price"]

print(df)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The new &lt;code&gt;revenue&lt;/code&gt; column is calculated for every row.&lt;/p&gt;

&lt;p&gt;You could also calculate a discount or profit margin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df["discount_rate"] = 0.05

df["discounted_revenue"] = (
    df["revenue"] * (1 - df["discount_rate"])
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Filtering records using conditions
&lt;/h3&gt;

&lt;p&gt;Management wants to know which transactions generated revenue above KES 300,000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;high_revenue = df[df["revenue"] &amp;gt; 300000]

print(high_revenue)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also apply multiple conditions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nairobi_laptops = df[
    (df["branch"] == "Nairobi") &amp;amp;
    (df["product"] == "Laptop")
]

print(nairobi_laptops)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parentheses are important when combining conditions with &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For a condition that excludes a particular category:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;non_laptop_sales = df[df["product"] != "Laptop"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cleaning missing values
&lt;/h3&gt;

&lt;p&gt;Real-world datasets are rarely perfect. A missing value might indicate an unrecorded transaction, an unavailable measurement, or an incomplete form.&lt;/p&gt;

&lt;p&gt;Identifying missing values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(df.isna())
print(df.isna().sum())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove rows containing any missing values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clean_df = df.dropna()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fill missing values with a known default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df["units_sold"] = df["units_sold"].fillna(0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also fill missing numerical values using a median:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;median_units = df["units_sold"].median()

df["units_sold"] = df["units_sold"].fillna(median_units)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please note that this can be appropriate in some analytical settings, but the decision should be guided by the meaning of the data and the analytical objective. Always we need to understand the business context for us to deal with missing values objectively and maintain the correctness and accuracy of our final product.&lt;/p&gt;

&lt;h3&gt;
  
  
  Removing duplicate records
&lt;/h3&gt;

&lt;p&gt;Duplicate records can inflate revenue, transaction counts, and other metrics.&lt;/p&gt;

&lt;p&gt;To identify duplicates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(df.duplicated().sum())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To remove fully duplicated rows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = df.drop_duplicates()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In production, first determine why the duplicates exist and whether one record contains more reliable information than another.For example, if a transaction ID uniquely identifies a transaction, use it to define duplicates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = df.drop_duplicates(
    subset=["transaction_id"],
    keep="first"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This assumes that the first record is the one you want to retain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Correcting data types
&lt;/h3&gt;

&lt;p&gt;Suppose revenue has been imported as text rather than a number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df["revenue"] = pd.to_numeric(
    df["revenue"],
    errors="coerce"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;errors="coerce"&lt;/code&gt; argument converts values that cannot be interpreted as numbers to missing values. &lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df["order_date"] = pd.to_datetime(
    df["order_date"],
    errors="coerce"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Date parsing is essential when doing time analysis. Pandas can  parse dates while loading a CSV:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.read_csv(
    "sales.csv",
    parse_dates=["order_date"]
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Grouping and aggregating data
&lt;/h3&gt;

&lt;p&gt;To answer meaningful business questions, grouping and aggregation plays a big part of it as it uncovers trends and patterns by summarizing.&lt;/p&gt;

&lt;p&gt;For us to know total revenue by branch, we can :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;branch_revenue = (
    df.groupby("branch")["revenue"]
      .sum()
      .reset_index()
)

print(branch_revenue)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To calculate average revenue by product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;product_performance = (
    df.groupby("product")["revenue"]
      .mean()
      .reset_index()
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to calculate several metrics together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;summary = (
    df.groupby("product")
      .agg(
          total_units=("units_sold", "sum"),
          total_revenue=("revenue", "sum"),
          average_revenue=("revenue", "mean")
      )
      .reset_index()
)

print(summary)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sorting and ranking results
&lt;/h3&gt;

&lt;p&gt;Let's say we want to know which products generate the most revenue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ranked_products = summary.sort_values(
    by="total_revenue",
    ascending=False
)

print(ranked_products)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setting the argument &lt;code&gt;ascending=False&lt;/code&gt; sorts from highest to lowest.&lt;/p&gt;

&lt;p&gt;We can also create a ranking column by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;summary["revenue_rank"] = (
    summary["total_revenue"]
    .rank(method="dense", ascending=False)
    .astype(int)
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This assigns rank 1 to the product with the highest revenue, with tied values receiving the same rank.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combining datasets with merge
&lt;/h3&gt;

&lt;p&gt;This is similar to Joins in SQL, Excel, or Power BI.&lt;/p&gt;

&lt;p&gt;Suppose you have a transaction table and a separate table containing branch locations.&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;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;branch_id&lt;/span&gt;&lt;span class="sh"&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revenue&lt;/span&gt;&lt;span class="sh"&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;400000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;360000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;240000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="n"&gt;branches&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;branch_id&lt;/span&gt;&lt;span class="sh"&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;branch_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Nairobi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mombasa&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Kisumu&lt;/span&gt;&lt;span class="sh"&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;p&gt;To combine them using a left merge to retain all records from the sales dataset and add matching branch information where available, by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;combined = sales.merge(
    branches,
    on="branch_id",
    how="left"
)

print(combined)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use other common join types such as &lt;code&gt;inner&lt;/code&gt;, &lt;code&gt;right&lt;/code&gt;, and &lt;code&gt;outer&lt;/code&gt; accordingly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exporting cleaned data
&lt;/h3&gt;

&lt;p&gt;Once your analysis is complete, you may need to share the results with Excel users, a database, or another analytics tool.&lt;/p&gt;

&lt;p&gt;Export to CSV:&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;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cleaned_sales.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Export to Excel:&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;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_excel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cleaned_sales.xlsx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;index=False&lt;/code&gt; argument prevents the DataFrame index from being written as an extra column.&lt;/p&gt;

&lt;p&gt;Now let's look at how our numerical engine works.&lt;/p&gt;

&lt;h2&gt;
  
  
  NumPy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is NumPy?
&lt;/h3&gt;

&lt;p&gt;NumPy, which is &lt;em&gt;Numerical Python&lt;/em&gt; in full, is a Python library for numerical computing. Its most common data structure is the multidimensional array, called the &lt;code&gt;ndarray&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;NumPy array is designed for efficient numerical computation and typically stores elements using a consistent data type.&lt;/p&gt;

&lt;p&gt;NumPy is powerful when our data is just a sequence of numbers. When our data contains product names, dates, branches, categories, and missing values, that's where Pandas comes in.&lt;/p&gt;

&lt;h3&gt;
  
  
  So how is NumPy important for our Journey?
&lt;/h3&gt;

&lt;p&gt;Say we have thousands of sales values. We want to calculate the total, average, standard deviation, or percentage change. We could write loops that process each value individually, which is kinda hectic. That's where NumPy comes in, providing optimised array operations that often perform such calculations more efficiently.&lt;/p&gt;

&lt;p&gt;NumPy is especially useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mathematical and statistical calculations.&lt;/li&gt;
&lt;li&gt;Working with vectors and matrices.&lt;/li&gt;
&lt;li&gt;Broadcasting operations across arrays.&lt;/li&gt;
&lt;li&gt;Random-number generation and simulations.&lt;/li&gt;
&lt;li&gt;Numerical operations used in scientific computing and machine learning.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Importing NumPy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np    #np is the conventional alias for NumPy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating NumPy arrays
&lt;/h3&gt;

&lt;p&gt;Say we record daily sales for five days.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;daily_sales = np.array([1200, 1500, 1800, 1300, 2200])

print(daily_sales)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are the ways to inspect an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(daily_sales.ndim)   # Number of dimensions (1D or 2D)
print(daily_sales.shape)  # Shape of the array 
print(daily_sales.size)   # Number of elements
print(daily_sales.dtype)  # Data type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Performing calculations without writing loops (Vectorization)
&lt;/h3&gt;

&lt;p&gt;** Vectorization **: performing an operation over an array without explicitly writing a Python loop for every element.&lt;/p&gt;

&lt;p&gt;Suppose every product's price increases by 10%. With NumPy, you can operate directly on the array without using loops.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prices = np.array([100, 200, 300, 400])

new_prices = prices * 1.10

print(new_prices)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A few NumPy mathematical operations
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sales = np.array([1200, 1500, 1800, 1300, 2200])

print("Total:", np.sum(sales))  #total sales
print("Average:", np.mean(sales)) #average performance
print("Median:", np.median(sales)) #median sales value
print("Minimum:", np.min(sales)) #lowest sales value
print("Maximum:", np.max(sales)) #highest sales value
print("Standard deviation:", np.std(sales)) #How much did sales vary around the average
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Filtering arrays with conditions
&lt;/h3&gt;

&lt;p&gt;For example, to get Sales greater than 1,500.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sales = np.array([1200, 1500, 1800, 1300, 2200])

high_sales = sales[sales &amp;gt; 1500]

print(high_sales)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Multidimensional arrays
&lt;/h3&gt;

&lt;p&gt;More often than not, real world numerical data has more than one dimension.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;weekly_sales = np.array([
    [1200, 1500, 1800],
    [1300, 1700, 2100],
    [1100, 1600, 1900]
])

print(weekly_sales)
print("Shape:", weekly_sales.shape)
print("Total:", np.sum(weekly_sales))
print("Column totals:", np.sum(weekly_sales, axis=0))
print("Row totals:", np.sum(weekly_sales, axis=1))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The array contains three rows and three columns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Broadcasting
&lt;/h3&gt;

&lt;p&gt;Broadcasting helps us to perform operations between compatible array shapes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prices = np.array([100, 200, 300])

discounted_prices = prices - 20

print(discounted_prices)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The scalar &lt;code&gt;20&lt;/code&gt; is broadcast across the array.&lt;/p&gt;

&lt;p&gt;Broadcasting becomes even more powerful when dealing with arrays of different but compatible shapes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prices = np.array([
    [100, 200, 300],
    [400, 500, 600]
])

tax_rates = np.array([0.16, 0.16, 0.16])

prices_with_tax = prices * (1 + tax_rates)

print(prices_with_tax)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The three tax rates align with the three columns, so the operation applies the relevant rate to each column in both rows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generating numerical sequences
&lt;/h3&gt;

&lt;p&gt;NumPy also helps create numerical sequences. &lt;code&gt;np.arange(start, stop, step)&lt;/code&gt; generates values from the starting point up to, but excluding, the stopping point.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = np.arange(0, 10, 2)

print(numbers)
&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 2 4 6 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a specified number of evenly spaced values:&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;values&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;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&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.  25.  50.  75. 100.]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unlike &lt;code&gt;arange&lt;/code&gt;, &lt;code&gt;linspace&lt;/code&gt; allows you to specify how many values you want.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handling missing numerical values
&lt;/h3&gt;

&lt;p&gt;NumPy includes &lt;code&gt;NaN&lt;/code&gt;, which represents a floating-point missing or invalid numerical value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;measurements = np.array([10, 20, np.nan, 40, 50])

print(np.mean(measurements))
print(np.nanmean(measurements))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The mean returns &lt;code&gt;NaN&lt;/code&gt; because a missing value is present. &lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;np.nanmean()&lt;/code&gt; However, helps us ignore &lt;code&gt;NaN&lt;/code&gt; values.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Final Stretch Home
&lt;/h1&gt;

&lt;p&gt;Tools Are Powerful, but thinking as a data analyst is the real skill. When we combine all these tools for our project, and an analytical and critical thinking mind. We become an unstoppable force in the world of analytics.&lt;br&gt;
We should never focus on "Which Python function ot tool should I use?"&lt;/p&gt;

&lt;p&gt;We should always to begin by asking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What problem am I trying to solve?&lt;/li&gt;
&lt;li&gt;What does each record represent?&lt;/li&gt;
&lt;li&gt;Is the data accurate and complete enough for the task?&lt;/li&gt;
&lt;li&gt;Which calculations are appropriate?&lt;/li&gt;
&lt;li&gt;What assumptions am I making?&lt;/li&gt;
&lt;li&gt;What can I responsibly conclude from the results?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is where the real power of data begins, and this is the final destination of our journey today. Think like an analyst!&lt;/p&gt;

</description>
      <category>uv</category>
      <category>panda</category>
      <category>numpy</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Data Cleaning Broken Down</title>
      <dc:creator>Daniel Mutwiri Mbabu</dc:creator>
      <pubDate>Wed, 07 Oct 2026 08:01:19 +0000</pubDate>
      <link>https://dev.to/daniel_mutwirimbabu/data-cleaning-broken-down-9a0</link>
      <guid>https://dev.to/daniel_mutwirimbabu/data-cleaning-broken-down-9a0</guid>
      <description>&lt;h1&gt;
  
  
  Data Cleaning: The Bane of Our Existence and the Reason Analysis Works.
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Why the duality, you might ask?&lt;/p&gt;

&lt;p&gt;There is a strange irony in the world of data: &lt;strong&gt;the work that nobody wants to do is often the work that matters most.&lt;/strong&gt; Data cleaning is arguably the bane of every data professional's existence. We spend hours chasing missing values, hunting down duplicates, fixing inconsistent dates, correcting misspelled categories, and asking why a column that should contain numbers is suddenly full of text. It is repetitive, frustrating, and rarely the glamorous part of data analysis. Yet, beneath all that frustration lies its greatest importance: &lt;strong&gt;clean data is the foundation of trustworthy analysis.&lt;/strong&gt; The most sophisticated dashboard, the most advanced SQL query, or the most powerful machine-learning model cannot compensate for fundamentally flawed data. Thus, before any clean or meaningful insight, data cleaning is inevitable. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Then, What Is Data Cleaning?
&lt;/h2&gt;

&lt;p&gt;Data cleaning is the process of detecting, correcting, removing, or appropriately handling inaccurate, incomplete, inconsistent, duplicated, or improperly formatted data. It's literally cleaning data. Only that, in this case, we don't use water and soap. We use logic, formulas, and repetitive, annoying little adjustments here and there.&lt;/p&gt;

&lt;p&gt;What makes data dirty? There are several potential problems when dealing with any data; I will name a few:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Different Casing for the same item. &lt;/li&gt;
&lt;li&gt;Dates in different formats.&lt;/li&gt;
&lt;li&gt;Missing values&lt;/li&gt;
&lt;li&gt;Ambiguous values, such as a negative sale, which may be invalid or may represent a legitimate refund. Or an end date that comes before the start date.&lt;/li&gt;
&lt;li&gt;Duplicates, and again I say duplicates.&lt;/li&gt;
&lt;li&gt;Inconsistent data types... I am already tired. In a nutshell, there are so many reasons a data set can be dirty.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. The importance of Cleaning Data
&lt;/h2&gt;

&lt;p&gt;I will quote the famous principle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Garbage in, garbage out.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If incorrect data enters an analytical process, even a sophisticated model can produce misleading results.&lt;/p&gt;

&lt;p&gt;Data cleaning is important because it improves:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Accuracy&lt;/strong&gt; - Corrects erroneous values and records.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt; - Ensures that the same concepts are represented in the same way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Completeness&lt;/strong&gt; - Identifies missing information and determines how it should be handled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reliability&lt;/strong&gt; - Makes analytical results more trustworthy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt; - Clean and standardized data is easier to query, transform, visualize, and analyze.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decision-making&lt;/strong&gt; - Business decisions based on inaccurate data can result in incorrect conclusions, financial losses, operational problems, or poor strategic decisions.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  3. How do we clean data becomes the next question.
&lt;/h2&gt;

&lt;p&gt;Tools will differ, but I would like to show the general data cleaning process. Whichever tool you may be using, these steps form the skeleton of data cleaning.&lt;/p&gt;

&lt;p&gt;I would follow these steps for any data cleaning task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
1. Understand the data (Context) 
2. Profile the data  
3. Identify the problems 
4. Decide on a uniform and standard way of correcting the data  
5. Clean the data
6. Validate the data 
7. Document 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1: Understanding the Data
&lt;/h3&gt;

&lt;p&gt;Before changing anything, we need to understand what the data represents. Understand the context of the data and the final purpose of cleaning the data. This step seems unnecessary, but it's very crucial. It will help you make the right decisions, know which data to keep, understand the dynamics of the purpose of analysis, and even make your work easier&lt;/p&gt;

&lt;p&gt;Here are a few questions you can ask to understand the data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What does each row represent?&lt;/li&gt;
&lt;li&gt;What does each column represent?&lt;/li&gt;
&lt;li&gt;What is the source of the data?&lt;/li&gt;
&lt;li&gt;What are the expected data types?&lt;/li&gt;
&lt;li&gt;What values are considered valid?&lt;/li&gt;
&lt;li&gt;What are the business rules?&lt;/li&gt;
&lt;li&gt;Which fields are mandatory?&lt;/li&gt;
&lt;li&gt;What constitutes a duplicate?&lt;/li&gt;
&lt;li&gt;Are negative values allowed?&lt;/li&gt;
&lt;li&gt;What date range should the data cover?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Profile the Data
&lt;/h3&gt;

&lt;p&gt;Data profiling means examining the dataset before cleaning it. This is a little different from Step 1. The main goal of this step is to categorize the data for a uniform kind of cleaning.&lt;/p&gt;

&lt;p&gt;Look at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of rows&lt;/li&gt;
&lt;li&gt;Number of columns&lt;/li&gt;
&lt;li&gt;Data types&lt;/li&gt;
&lt;li&gt;Missing values&lt;/li&gt;
&lt;li&gt;Unique values&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Minimum and maximum values&lt;/li&gt;
&lt;li&gt;Average and median&lt;/li&gt;
&lt;li&gt;Frequency distributions&lt;/li&gt;
&lt;li&gt;Outliers&lt;/li&gt;
&lt;li&gt;Invalid values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, if an &lt;code&gt;Age&lt;/code&gt; column contains &lt;code&gt;-5&lt;/code&gt; and &lt;code&gt;150&lt;/code&gt;, this should immediately raise questions. But also does not mean you automatically delete them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; A value that looks unusual may actually be valid.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 3: Identify Data Quality Problems
&lt;/h3&gt;

&lt;p&gt;Identify common data-quality problems systematically. They include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Missing values&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Incorrect data types&lt;/li&gt;
&lt;li&gt;Inconsistent formatting&lt;/li&gt;
&lt;li&gt;Invalid values&lt;/li&gt;
&lt;li&gt;Outliers&lt;/li&gt;
&lt;li&gt;Spelling inconsistencies&lt;/li&gt;
&lt;li&gt;Incorrect dates&lt;/li&gt;
&lt;li&gt;Leading and trailing spaces&lt;/li&gt;
&lt;li&gt;Inconsistent categorical values&lt;/li&gt;
&lt;li&gt;Broken relationships between tables&lt;/li&gt;
&lt;li&gt;Incorrect units&lt;/li&gt;
&lt;li&gt;Calculation errors&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Decide on a uniform and standard way of correcting the data
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Missing Values
&lt;/h4&gt;

&lt;p&gt;How do you treat unavailable information?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rule of Thumb: Different data sets with missing values may need different handling of missing data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A Missing value can be in the form of: &lt;code&gt;NULL&lt;/code&gt;, Blank, Empty string, &lt;code&gt;N/A&lt;/code&gt;, &lt;code&gt;NA&lt;/code&gt;, &lt;code&gt;Unknown&lt;/code&gt;,&lt;code&gt;-&lt;/code&gt;&lt;code&gt;0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please note carefully that these &lt;strong&gt;CANNOT&lt;/strong&gt; be treated as equivalents. For Instance: &lt;strong&gt;0&lt;/strong&gt; means the value is actually zero.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Common missing values handling approaches include:&lt;/p&gt;

&lt;h5&gt;
  
  
  1. Remove
&lt;/h5&gt;

&lt;p&gt;Remove records when the missing information makes the record unusable.&lt;/p&gt;

&lt;h5&gt;
  
  
  2. Impute
&lt;/h5&gt;

&lt;p&gt;Replace the missing value using a reasonable estimate such as the mean, the median, or the mode for text. But always remember to document the logic used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mean - for data with a normal distribution (no outliers)&lt;/li&gt;
&lt;li&gt;Median - for data with outliers(extremes)&lt;/li&gt;
&lt;li&gt;Mode - the most recurring text&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10, 12, NULL, 14

and

10, 1000, NULL, -20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The missing value could potentially be replaced with the mean or median, respectively, depending on the situation.&lt;/p&gt;

&lt;h5&gt;
  
  
  3. Use a default value
&lt;/h5&gt;

&lt;p&gt;Some of the default values that can be used are: NULL, "Unknown", "Not Provided"&lt;/p&gt;

&lt;p&gt;Ensure the default value is uniform across a common set of data.&lt;br&gt;
.&lt;/p&gt;
&lt;h5&gt;
  
  
  4. Leave it missing
&lt;/h5&gt;

&lt;p&gt;Sometimes the best decision is to keep the missing value. The correct approach depends on the &lt;strong&gt;business meaning and analytical objective&lt;/strong&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Duplicate Data
&lt;/h4&gt;

&lt;p&gt;This is when the same record appears more than once.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Order ID&lt;/th&gt;
&lt;th&gt;Customer&lt;/th&gt;
&lt;th&gt;Sales&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1001&lt;/td&gt;
&lt;td&gt;John&lt;/td&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1002&lt;/td&gt;
&lt;td&gt;Mary&lt;/td&gt;
&lt;td&gt;700&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1001&lt;/td&gt;
&lt;td&gt;John&lt;/td&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If each order should have a unique &lt;code&gt;Order ID&lt;/code&gt;, the second occurrence of order &lt;code&gt;1001&lt;/code&gt; may be a duplicate.&lt;/p&gt;

&lt;p&gt;It is, however, important to investigate duplicate-looking records before deleting.&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 plaintext"&gt;&lt;code&gt;John | Kenya | 500
John | Kenya | 500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;could represent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A duplicate transaction&lt;/li&gt;
&lt;li&gt;Two legitimate transactions&lt;/li&gt;
&lt;li&gt;Two separate orders with missing identifiers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Never remove duplicates simply because two rows look identical. Understand the business rules first.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Standardizing Text
&lt;/h4&gt;

&lt;p&gt;Text inconsistencies are extremely common, especially casing problems when representing the same category. For example: Kenya, kenya, KENYA, Kenya&lt;/p&gt;

&lt;p&gt;Cleaning text involves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removing leading spaces&lt;/li&gt;
&lt;li&gt;Removing trailing spaces&lt;/li&gt;
&lt;li&gt;Standardizing casing (Lower/Upper/Proper cases)&lt;/li&gt;
&lt;li&gt;Correcting spelling&lt;/li&gt;
&lt;li&gt;Standardizing abbreviations&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Data Types
&lt;/h4&gt;

&lt;p&gt;Every field should have its appropriate data type. An Integer for an Integer, Decimal for Decimal...&lt;/p&gt;

&lt;p&gt;Correct data types are essential for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculations&lt;/li&gt;
&lt;li&gt;Sorting&lt;/li&gt;
&lt;li&gt;Filtering&lt;/li&gt;
&lt;li&gt;Aggregation&lt;/li&gt;
&lt;li&gt;Joins&lt;/li&gt;
&lt;li&gt;Time-series analysis&lt;/li&gt;
&lt;/ul&gt;

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

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

&lt;/div&gt;



&lt;p&gt;Although it looks like a number, it may actually be stored as text. This creates problems when calculating:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1500 + 500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"2026-05-01"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;may be stored as text instead of a date.&lt;/p&gt;

&lt;h4&gt;
  
  
  Date and Time Cleaning
&lt;/h4&gt;

&lt;p&gt;Dates are particularly problematic because different systems use different formats.&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 plaintext"&gt;&lt;code&gt;01/05/2026
2026-05-01
2026/05/01
May 1, 2026
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These may represent the same date.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;01/05/2026
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;could mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 May 2026&lt;/li&gt;
&lt;li&gt;January 5, 2026&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;depending on the regional format.&lt;/p&gt;

&lt;p&gt;Dates should therefore be standardized and converted to an actual date data type whenever possible.&lt;/p&gt;

&lt;h4&gt;
  
  
  Outliers
&lt;/h4&gt;

&lt;p&gt;An outlier is a value that is unusually different from other observations.&lt;/p&gt;

&lt;p&gt;Suppose sales values are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500
600
450
700
550
520
50000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;50,000&lt;/code&gt; is potentially an outlier.&lt;/p&gt;

&lt;p&gt;But an outlier isn't automatically an error.&lt;/p&gt;

&lt;p&gt;It could represent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A large legitimate transaction&lt;/li&gt;
&lt;li&gt;A special customer&lt;/li&gt;
&lt;li&gt;A data-entry error&lt;/li&gt;
&lt;li&gt;Fraud&lt;/li&gt;
&lt;li&gt;A one-time event&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Identify outliers; don't automatically delete them.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 5: Data Validation
&lt;/h3&gt;

&lt;p&gt;After cleaning, the data should be validated.&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are duplicates gone?&lt;/li&gt;
&lt;li&gt;Are required fields populated?&lt;/li&gt;
&lt;li&gt;Are data types correct?&lt;/li&gt;
&lt;li&gt;Are values within acceptable ranges?&lt;/li&gt;
&lt;li&gt;Are categories standardized?&lt;/li&gt;
&lt;li&gt;Are dates valid?&lt;/li&gt;
&lt;li&gt;Are relationships between tables correct?&lt;/li&gt;
&lt;li&gt;Did the cleaning process accidentally remove valid data?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Validation ensures that cleaning didn't create new problems.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Data Cleaning is the foundation we build all our data systems upon. Get it right, and the pipelines, the analytics, and the business decisions become seamless and valuable; get it wrong, and we miss the mark!&lt;/p&gt;

</description>
      <category>powerquery</category>
      <category>powerbi</category>
      <category>python</category>
      <category>sql</category>
    </item>
    <item>
      <title>The Paradox of Git and GitHub: Version Control</title>
      <dc:creator>Daniel Mutwiri Mbabu</dc:creator>
      <pubDate>Wed, 12 Aug 2026 13:40:18 +0000</pubDate>
      <link>https://dev.to/daniel_mutwirimbabu/the-paradox-of-git-and-github-version-control-bkk</link>
      <guid>https://dev.to/daniel_mutwirimbabu/the-paradox-of-git-and-github-version-control-bkk</guid>
      <description>&lt;p&gt;Often we get caught in the crossfire of big technological terminology, and we have so little to do but get blasted. For me, and I bet many others, Git and GitHub must be one of those! But for how long can we sit by and feel absolutely clueless, yet we can armour up at our own will? That's what I intend to do with this article. Let's break down this paradox together!&lt;/p&gt;

&lt;h2&gt;
  
  
  So What is Git and GitHub?
&lt;/h2&gt;

&lt;p&gt;Are they branches of the same Franchise that chose different names? Certainly not. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Definition&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Git&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;It's the tool that tracks your changes to your projects and runs locally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;It's a website that stores your Git history in the cloud for Collaboration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Git&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is a version control system that runs on your local machine, tracking every change you make to your code over time. It allows you to go back to any previous state, and lets multiple people work on the same project at the same time without overwriting each other.&lt;/p&gt;

&lt;p&gt;Without Git, teams share code by emailing files or editing the same folder. Both approaches lead to the same outcome, but in this case, someone's work gets lost. Git solves this permanently.&lt;/p&gt;

&lt;p&gt;Every developer has the full project history on their own machine - not just the latest version.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;GitHub&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt; is the website that stores your git history/git repositories in the cloud. (It does not run locally on your machine). It stores repositories online to enable collaboration.&lt;/p&gt;

&lt;p&gt;Mainly used to share code, review changes, manage issues, and Continuous Integration and Continuous Delivery (CI/CD)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In a nutshell&lt;/strong&gt;&lt;br&gt;
Git is like MS Word that tracks all the changes, while GitHub is the Google Drive where you upload the Word document for collaboration.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Common terminologies used in the Git/GitHub Environment...
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Repository (repo)&lt;/td&gt;
&lt;td&gt;It's a Git Project Folder that Git is tracking.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit&lt;/td&gt;
&lt;td&gt;This is a saved snapshot/state of your project at a specific point in time.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Branch&lt;/td&gt;
&lt;td&gt;It's a parallel version of the project - you experiment here without touching the main code.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remote&lt;/td&gt;
&lt;td&gt;It's the online stored copy of the repo, usually on GitHub.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Push&lt;/td&gt;
&lt;td&gt;It's to send your commits/changes to GitHub&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pull&lt;/td&gt;
&lt;td&gt;It's to bring others' commits down to your local machine.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  So how do you get started on Git and GitHub?...
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Installing Git
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Linux (Ubuntu)
&lt;/h4&gt;

&lt;p&gt;Run the commands below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git &lt;span class="nt"&gt;-y&lt;/span&gt;
git &lt;span class="nt"&gt;--version&lt;/span&gt;          &lt;span class="c"&gt;# confirm: git version 2.x.x&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Windows
&lt;/h4&gt;

&lt;p&gt;Download from &lt;a href="https://git-scm.com/download/win" rel="noopener noreferrer"&gt;https://git-scm.com/download/win&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Always run Git commands inside Git Bash CLI, not on other  CLIs such as Command Prompt or PowerShell.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  macOS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xcode-select &lt;span class="nt"&gt;--install&lt;/span&gt;    &lt;span class="c"&gt;# installs Git via Xcode CLI tools&lt;/span&gt;
&lt;span class="c"&gt;# OR if you have Homebrew:&lt;/span&gt;
brew &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; After the installation. A first-time configuration is necessary to connect your local Git to GitHub (Remote).&lt;/p&gt;

&lt;h4&gt;
  
  
  Opening Git Bash CLI for Windows and first-time configuration.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Create a New Folder (Location? Upto you)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxr5pgh7zhchalitxa85k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxr5pgh7zhchalitxa85k.png" alt=" " width="777" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right-click the newly created Folder to select more options if you cannot view "Open Git Bash Here".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzdy2bef1yk8tdd49m0du.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzdy2bef1yk8tdd49m0du.png" alt=" " width="542" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Git Bash will open, and you have to initialize Git to do any Configurations. To initialize Git, run the command:
&lt;code&gt;git init&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsezx8i7g6wffsszxiae3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsezx8i7g6wffsszxiae3.png" alt=" " width="694" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assuming you already have a GitHub account set up, run these commands in Git Bash for the first-time configuration.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name  &lt;span class="s2"&gt;"Your Full Name"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email &lt;span class="s2"&gt;"you@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Where: "Your Full Name" = "GitHub Account Name"&lt;br&gt;
       "&lt;a href="mailto:you@example.com"&gt;you@example.com&lt;/a&gt;" = "Email address to the GitHub Account Name"&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating Your GitHub Account
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://github.com" rel="noopener noreferrer"&gt;https://github.com&lt;/a&gt; and click Sign up&lt;/li&gt;
&lt;li&gt;Choose a professional username&lt;/li&gt;
&lt;li&gt;Verify your email address&lt;/li&gt;
&lt;li&gt;Add a profile picture and a short bio&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Quick Question
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;After configuring Git, how does the actual information flow between local (Git) and remote (GitHub)?&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Answer.
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;SSH / HTTPS &lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  The Communication Channels.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;SSH&lt;/strong&gt; (Secure Shell Protocol) uses a key pair to prove your identity without ever sending a password across the network.&lt;br&gt;
&lt;strong&gt;HTTPS&lt;/strong&gt; is an application layer protocol responsible for securely transporting the Git communication between your computer and GitHub. &lt;/p&gt;
&lt;h4&gt;
  
  
  SSH vs HTTPS.
&lt;/h4&gt;

&lt;p&gt;Which one do I use? Both are secure communication methods. You should not think SSH is secure and HTTPS is not. With HTTPS, GitHub uses a personal access token (PAT) or a credential manager rather than your GitHub account password.&lt;/p&gt;

&lt;p&gt;Ideally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use SSH if it's your own machine, and you use GitHub regularly.&lt;/li&gt;
&lt;li&gt;Use HTTPS if you're on a machine/network where SSH setup is inconvenient, restricted, or temporary.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;SSH&lt;/th&gt;
&lt;th&gt;HTTPS&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Authentication Automatic - key pair handles it silently&lt;/td&gt;
&lt;td&gt;Requires a Personal Access Token (not your password - GitHub removed that in 2021)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Setup effort   15 minutes once per machine&lt;/td&gt;
&lt;td&gt;Token needed for each machine; expires and must be refreshed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Daily use  Push and pull with no prompts at all&lt;/td&gt;
&lt;td&gt;Prompted for credentials unless you store the token&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for   Personal machines, servers, daily work&lt;/td&gt;
&lt;td&gt;One-off cloning; environments where SSH port is blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  THE CORE FLOW
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                   YOUR COMPUTER
            ┌─────────────────────┐
            │                     │
            │   Working Directory │
            │          ↓          │
            │        git add      │
            │          ↓          │
            │   Staging Area      │
            │          ↓          │
            │       git commit    │
            │          ↓          │
            │   Local Repository  │
            │                     │
            └─────────┬───────────┘
                      │
                   git push
                      │
                      ▼
            ┌─────────────────────┐
            │       GitHub        │
            │                     │
            │ Remote Repository   │
            └─────────────────────┘
                      │
                   git pull
                      │
                      ▼
            ┌─────────────────────┐
            │   Local Repository  │
            └─────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To break this down,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create/change a file locally&lt;/strong&gt;&lt;br&gt;
Suppose your GitHub repository is:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You clone it onto your computer:&lt;br&gt;
&lt;code&gt;git clone git@github.com:Danielmutwiri/JCARS.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will have all the files related to JCARS, e.g., the README.md file, etc&lt;/p&gt;

&lt;p&gt;Git creates a &lt;strong&gt;local repository&lt;/strong&gt; containing the project's history and also remembers where the remote repository is.&lt;/p&gt;

&lt;p&gt;To verify,&lt;br&gt;
&lt;code&gt;git remote -v&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will see&lt;/p&gt;

&lt;p&gt;&lt;code&gt;origin  git@github.com:Danielmutwiri/JCARS.git (fetch)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;origin  git@github.com:Danielmutwiri/JCARS.git (push)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Origin&lt;/strong&gt; is the conventional name given to a GitHub repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. You modify a file&lt;/strong&gt;&lt;br&gt;
Suppose you modify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git will see README.md (Modified), but GitHub knows nothing about this change yet. Changing a file does not automatically change your Git repository or GitHub.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;git add&lt;/code&gt; moves the change to staging&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add README.md&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The change moves from the working directory to the staging area&lt;br&gt;
It's like saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Git, I want this particular change to be included in my next commit."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To verify, use this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. &lt;code&gt;git commit&lt;/code&gt; stores the change locally&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;git commit -m "Update README.md"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Git creates a &lt;strong&gt;commit&lt;/strong&gt; in your local repository. But GitHub still hasn't received the commit yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. &lt;code&gt;git push&lt;/code&gt; sends your commits to GitHub&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;git push origin main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is where the actual communication with GitHub occurs. Git transfers the necessary Git commit information to the remote repository. GitHub then updates its remote branch, and now they are in sync.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. What happens if some other developer changes GitHub?&lt;/strong&gt;&lt;br&gt;
On their computer, a change has happened, say 'change A'. Also, GitHub is updated, but your local PC is lagging. Use &lt;code&gt;git fetch&lt;/code&gt;/&lt;code&gt;git pull&lt;/code&gt; to retrieve information from GitHub and get your local PC up to speed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git fetch origin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Git will contact GitHub and retrieve information about changes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;fetch&lt;/code&gt; is relatively safe: it downloads information but does not automatically modify your working files.&lt;code&gt;git pull&lt;/code&gt; however, goes one step further.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;git pull origin main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Git will perform: git fetch + git merge. Your local branch is then brought up to date. Modern Git can also be configured to use rebase instead of merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub is not the "master copy" of Git itself.&lt;/strong&gt; Your local repository contains the full Git history too. GitHub is a &lt;strong&gt;remote repository&lt;/strong&gt; that provides collaboration, backup, hosting, and pull requests. Now you have the power to go and do some version control.&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>versioncontrol</category>
    </item>
    <item>
      <title>Connecting Power BI to a SQL Database</title>
      <dc:creator>Daniel Mutwiri Mbabu</dc:creator>
      <pubDate>Thu, 23 Jul 2026 08:53:03 +0000</pubDate>
      <link>https://dev.to/daniel_mutwirimbabu/connecting-power-bi-to-a-sql-database-1nek</link>
      <guid>https://dev.to/daniel_mutwirimbabu/connecting-power-bi-to-a-sql-database-1nek</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwdmm0qgyhrky1lmcdbj9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwdmm0qgyhrky1lmcdbj9.png" alt=" " width="799" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Oftentimes we need to clean, model, and report insights from data stored in databases. Sometimes the data can be stored in a local SQL database or in a cloud-based SQL database. Today we will dive into the nitty-gritty of this endeavor using Power BI as your reporting tool and a SQL database as our storage.&lt;/p&gt;

&lt;h1&gt;
  
  
  Understanding Data Connectivity Modes
&lt;/h1&gt;

&lt;p&gt;To connect a reporting and analysis tool such as Power BI to a SQL Database, understanding how it connects to the database is crucial. There are three primary connection modes. Each serves a different purpose depending on your reporting needs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt; Import Mode&lt;/li&gt;
&lt;li&gt; Direct Query&lt;/li&gt;
&lt;li&gt; Live Connection&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1. Import Mode&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;br&gt;
Power BI imports all selected data into its in-memory VertiPaq engine.&lt;br&gt;
Reports query the imported data instead of the SQL database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ideal when&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data changes daily or a few times per day.&lt;/li&gt;
&lt;li&gt;You need high-performance dashboards.&lt;/li&gt;
&lt;li&gt;Complex calculations and relationships are required.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;em&gt;A sales database updates overnight, and management reviews reports each morning.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. DirectQuery Mode&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;br&gt;
No data is stored in Power BI (except metadata and optional cache).&lt;br&gt;
Every filter, slicer, or visual generates a SQL query against the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ideal when&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data changes every few minutes.&lt;/li&gt;
&lt;li&gt;Databases contain hundreds of millions of rows.&lt;/li&gt;
&lt;li&gt;Data cannot be copied due to compliance or storage constraints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;em&gt;A call center dashboard showing live customer support activity.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Performance Tips&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create indexes on frequently filtered columns.&lt;/li&gt;
&lt;li&gt;Use star schema design.&lt;/li&gt;
&lt;li&gt;Minimize calculated columns in Power BI.&lt;/li&gt;
&lt;li&gt;Reduce visual complexity.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;3.Live Connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;br&gt;
Instead of connecting directly to SQL, Power BI connects to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQL Server Analysis Services (SSAS)&lt;/li&gt;
&lt;li&gt;Azure Analysis Services (AAS)&lt;/li&gt;
&lt;li&gt;Another Power BI semantic model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The semantic model handles calculations, relationships, and security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ideal when&lt;/strong&gt;&lt;br&gt;
An organization has a centralized BI team managing enterprise models.&lt;br&gt;
Multiple reports should use the same governed data model.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Scenario&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Recommended Mode&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fast executive dashboards&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Import&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real-time operational dashboards&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;DirectQuery&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Very large databases&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;DirectQuery&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enterprise semantic model already exists&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Live Connection&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Need both speed and fresh data&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Composite Model&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Connecting Power BI to a Local SQL Database
&lt;/h1&gt;

&lt;p&gt;A local SQL Database runs on your local machine. Therefore, connecting to it is easy!&lt;br&gt;
&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQL Server installed (e.g., SQL Server Express, Developer, or Standard Edition)&lt;/li&gt;
&lt;li&gt;SQL Server service is running&lt;/li&gt;
&lt;li&gt;You know:&lt;/li&gt;
&lt;li&gt;Server name&lt;/li&gt;
&lt;li&gt;Database name&lt;/li&gt;
&lt;li&gt;Authentication method (Windows or SQL Server Authentication)&lt;/li&gt;
&lt;li&gt;Power BI Desktop is installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Open Power BI Desktop&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch Power BI Desktop.&lt;/li&gt;
&lt;li&gt;Click Get Data on the Home ribbon.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flodreg37p5anf1bp2s5q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flodreg37p5anf1bp2s5q.png" alt=" " width="782" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select SQL Server. (In this case, we are using a Postgres Server)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb2217jk8gdoz00htnlk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb2217jk8gdoz00htnlk5.png" alt=" " width="800" height="768"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Connect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Enter Connection Details&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You'll be prompted for:&lt;/p&gt;

&lt;p&gt;Server and Database information. &lt;br&gt;
For a local connection, input the server credentials as: &lt;code&gt;127.0.0.1:5432&lt;/code&gt;&lt;br&gt;
  &lt;em&gt;where th 5432 is the port number&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiwjfxe0k5k8qx54hhd2b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiwjfxe0k5k8qx54hhd2b.png" alt=" " width="783" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Choose Connectivity Mode&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You'll have two options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Import (recommended)&lt;/li&gt;
&lt;li&gt;DirectQuery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Authentication&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows Authentication (Most Common)&lt;/strong&gt;&lt;br&gt;
Uses your Windows login credentials.&lt;/p&gt;

&lt;p&gt;Select: Windows &amp;gt; Then click Connect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Server Authentication (Authentication details you input while installing your local SQL server)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose: Database &amp;gt; Enter: Username and Password&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcpvctmal4eq6xub0ordn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcpvctmal4eq6xub0ordn.png" alt=" " width="743" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Connect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Select Tables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Power BI will display all tables and views. Select the tables you need. Click Load to import them or Transform Data to clean them in Power Query before loading.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5qao4k606l8cuclw7771.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5qao4k606l8cuclw7771.png" alt=" " width="800" height="621"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Connecting Power BI to a Cloud-based SQL Database
&lt;/h1&gt;

&lt;p&gt;For this, the cloud service provider is Aiven.&lt;/p&gt;

&lt;p&gt;Cloud databases like Aiven PostgreSQL offer scalable and flexible data storage but require secure internet-based connections. To protect data in transit, they use encryption. Before Power BI can connect, the local machine must trust the cloud provider's Certificate Authority (CA), allowing it to verify the database server's identity and establish a secure connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Collect Aiven Connection Details&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to your Aiven Console and open your PostgreSQL service. Note the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzz35b3e8iyokox0n1j39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzz35b3e8iyokox0n1j39.png" alt=" " width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Host (e.g., pg-12345-project.aivencloud.com)&lt;/li&gt;
&lt;li&gt;Port (usually 12345 or 5432)&lt;/li&gt;
&lt;li&gt;Database name&lt;/li&gt;
&lt;li&gt;Username&lt;/li&gt;
&lt;li&gt;Password&lt;/li&gt;
&lt;li&gt;CA Certificate&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Install the PostgreSQL ODBC/Npgsql Driver (if required)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Power BI uses PostgreSQL drivers to connect. &lt;/li&gt;
&lt;li&gt;Download and install the latest PostgreSQL (Npgsql) driver.&lt;/li&gt;
&lt;li&gt;Restart Power BI Desktop after installation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Trust the Aiven CA Certificate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since Aiven uses SSL encryption, Windows must trust the Certificate Authority. This helps Power BI trust the Aiven Postgres server.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;To connect Power BI to the Database without the certificate, this error occurs.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1okmx7qfkt8j9z5dkr69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1okmx7qfkt8j9z5dkr69.png" alt=" " width="592" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Locate the downloaded ca.pem file.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F24sbpbk6ac5lywe57lnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F24sbpbk6ac5lywe57lnr.png" alt=" " width="800" height="49"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import it into the Windows Trusted Root Certification Authorities:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpa9pybjvh0rlxaa4fn8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpa9pybjvh0rlxaa4fn8w.png" alt=" " width="452" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9l4tuwfmuv6ko2pgjyqf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9l4tuwfmuv6ko2pgjyqf.png" alt=" " width="780" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Import&amp;gt; In the import wizard, click Next&amp;gt; Browse for the downloaded  CA file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxbv81pykea8ttu18ip29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxbv81pykea8ttu18ip29.png" alt=" " width="670" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faffa79vk8y1v1ve59ip5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faffa79vk8y1v1ve59ip5.png" alt=" " width="670" height="646"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add Certificates for the Computer Account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4ptrvwo7n31ne1wy54ei.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4ptrvwo7n31ne1wy54ei.png" alt=" " width="617" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzbu3kj74ovfxhbliluiu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzbu3kj74ovfxhbliluiu.png" alt=" " width="641" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Open Power BI Desktop&lt;/strong&gt; &lt;em&gt;( Same as for local connection steps 1 to 3)&lt;/em&gt;&lt;br&gt;
Select Home → Get Data → Choose PostgreSQL database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Enter the Server Details&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fill in the fields as per the data on your Aiven service page:&lt;br&gt;
&lt;em&gt;Server:    hostname:port (pg-12345-project.aivencloud.com:12345)&lt;br&gt;
Database: Database name (defaultdb)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmmi5skdgjuu743cuw5lk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmmi5skdgjuu743cuw5lk.png" alt=" " width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click OK.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Authenticate&lt;/strong&gt; - if connecting first time&lt;/p&gt;

&lt;p&gt;Choose Database Authentication: Username &amp;gt; Password&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw39t42jlsbwxsx5fqbia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw39t42jlsbwxsx5fqbia.png" alt=" " width="797" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Connect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Select Tables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Power BI will display the PostgreSQL schema. Choose the required tables or views.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs2xaxopws0s1aocd5i83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs2xaxopws0s1aocd5i83.png" alt=" " width="800" height="705"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Load to import the data or Transform Data to clean it in Power Query before loading.&lt;/p&gt;

&lt;h1&gt;
  
  
  Parting Shot...
&lt;/h1&gt;

&lt;p&gt;Every dashboard begins with a connection. This is where the strength of Power BI comes in: Interconnectivity! Whether your data resides on a local server or in the cloud, mastering secure database connectivity equips you to spend less time troubleshooting and more time discovering the stories hidden within your data. After all, data only becomes valuable when it is transformed into meaningful insights.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>powerfuldevs</category>
      <category>dbeaver</category>
    </item>
    <item>
      <title>How Excel is Used in Real-World Data Analysis</title>
      <dc:creator>Daniel Mutwiri Mbabu</dc:creator>
      <pubDate>Sun, 07 Jun 2026 14:58:01 +0000</pubDate>
      <link>https://dev.to/daniel_mutwirimbabu/how-excel-is-used-in-real-world-data-analysis-226g</link>
      <guid>https://dev.to/daniel_mutwirimbabu/how-excel-is-used-in-real-world-data-analysis-226g</guid>
      <description>&lt;p&gt;The eagle first learns to walk before it masters the sky. In the world of data analysis, Excel is often the starting point of that journey. It helps us clean, organize, analyze, and visualize data in ways that reveal valuable patterns and opportunities. What begins as simple rows, columns, and calculations soon transforms into a powerful analytical tool that enables users to uncover trends, solve problems, and make informed decisions based on data rather than assumptions.&lt;/p&gt;

&lt;p&gt;I recently joined an official Microsoft Excel class. Although I had used Excel before and was required to learn it on the job due to its importance in business, I quickly discovered that there is always something new to learn. I joined the class believing I had a solid understanding of Excel, but I soon realized that beneath its simplicity lies remarkable sophistication. This balance between simplicity and power is what makes Excel such an indispensable tool.&lt;/p&gt;

&lt;p&gt;One of the key lessons I have learned is that data analysis is not just about mastering formulas and features; it is also about understanding the business environment and the problem being solved. A good data analyst should possess both technical and business knowledge. Understanding what questions to ask is just as important as knowing how to manipulate and analyze the data.&lt;/p&gt;

&lt;p&gt;Excel plays a vital role in several real-world applications.** In business decision-making,** organizations collect large amounts of data from sales, operations, customers, and employees. Analysts use Excel to identify trends, determine which products generate the most revenue, evaluate branch performance, and forecast future demand. These insights help businesses make informed decisions regarding inventory management, staffing, and investments.&lt;br&gt;
Excel is also widely used in &lt;strong&gt;financial reporting&lt;/strong&gt;. Organizations use it to compare actual spending against budgets, forecast revenues, evaluate investments, and identify potential financial risks. These analyses provide management with the information needed to make sound financial decisions.&lt;br&gt;
In &lt;strong&gt;marketing&lt;/strong&gt;, Excel helps measure the effectiveness of advertising campaigns, social media activities, and customer engagement efforts. By analyzing metrics such as website traffic, conversion rates, and customer acquisition costs, organizations can determine which strategies are delivering the best results and allocate resources more effectively.&lt;/p&gt;

&lt;p&gt;One of the most valuable skills I have learned is data cleaning. Clean data forms the foundation of reliable analysis. Excel provides numerous tools and functions that support this process, including&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COUNTIFS(), TRIM(), VALUE(), DATEDIF(), YEAR(), TODAY(), NOW(), IFERROR(), and SUMIFS().
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Features such as &lt;em&gt;Find and Replace, Conditional Formatting, Data Validation, Multi-Sort, and handling blanks&lt;/em&gt; help ensure data accuracy and consistency. Data cleaning also involves &lt;em&gt;checking whether data is realistic and free from errors, such as identifying impossible employee ages or inconsistent entries.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Learning Excel has greatly increased my appreciation for data-driven decision-making. Whether in business, finance, marketing, or personal projects, I now recognize the importance of relying on data rather than assumptions. Excel has transformed the way I see information by showing me how raw data can be organized, analyzed, and converted into actionable insights. As I continue learning, I appreciate even more how a tool that appears simple on the surface can become a powerful means of solving complex real-world problems.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>data</category>
      <category>analytics</category>
    </item>
  </channel>
</rss>
