<?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: NelimaL</title>
    <description>The latest articles on DEV Community by NelimaL (@nelima).</description>
    <link>https://dev.to/nelima</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%2F3821899%2F92a69dc3-b382-4d88-88ff-02ba548d92be.jpeg</url>
      <title>DEV Community: NelimaL</title>
      <link>https://dev.to/nelima</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nelima"/>
    <language>en</language>
    <item>
      <title>Using Machine Learning to Direct Limited HIV Programme Resources to Communities with the Greatest Need</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Tue, 11 Aug 2026 09:24:01 +0000</pubDate>
      <link>https://dev.to/nelima/using-machine-learning-to-direct-limited-hiv-programme-resources-to-communities-with-the-greatest-4pef</link>
      <guid>https://dev.to/nelima/using-machine-learning-to-direct-limited-hiv-programme-resources-to-communities-with-the-greatest-4pef</guid>
      <description>&lt;p&gt;Imagine working as a Data Analyst in a healthcare Non-Governmental Organization (NGO) implementing HIV and AIDS programmes across several communities.&lt;/p&gt;

&lt;p&gt;The organization has limited resources. There may not be enough funding, healthcare workers, testing kits, transport, outreach teams, or community programmes to serve every community at the same intensity.&lt;/p&gt;

&lt;p&gt;This creates an important question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How can we use data and machine learning to direct limited programme resources to communities with the greatest need?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is where Machine Learning (ML) can become valuable.&lt;br&gt;
Rather than distributing resources equally across all communities, an NGO can use historical programme data to identify communities experiencing greater HIV-related service gaps or higher levels of need. Resources can then be prioritized based on evidence.&lt;/p&gt;
&lt;h1&gt;
  
  
  What Is Machine Learning?
&lt;/h1&gt;

&lt;p&gt;Machine Learning is a branch of Artificial Intelligence that enables computers to learn patterns from data and use those patterns to make predictions or support decisions.&lt;/p&gt;

&lt;p&gt;Instead of manually creating rules for every situation, you provide the algorithm with historical data and allow it to identify relationships within that data.&lt;br&gt;
For example, the NGO could have this information about different communities:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Community&lt;/th&gt;
&lt;th&gt;HIV Testing Coverage&lt;/th&gt;
&lt;th&gt;ART Coverage&lt;/th&gt;
&lt;th&gt;Missed Appointments&lt;/th&gt;
&lt;th&gt;Outreach Activities&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Community A&lt;/td&gt;
&lt;td&gt;85%&lt;/td&gt;
&lt;td&gt;90%&lt;/td&gt;
&lt;td&gt;5%&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Community B&lt;/td&gt;
&lt;td&gt;52%&lt;/td&gt;
&lt;td&gt;61%&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Community C&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;td&gt;15%&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Community D&lt;/td&gt;
&lt;td&gt;40%&lt;/td&gt;
&lt;td&gt;55%&lt;/td&gt;
&lt;td&gt;32%&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Looking at this data, &lt;strong&gt;Community D&lt;/strong&gt; appears to have greater programme gaps than Community A. However, in a real programme, the decision should not be based on one indicator alone.&lt;br&gt;
Machine learning can analyse many variables simultaneously to identify communities that may require greater attention.&lt;/p&gt;
&lt;h1&gt;
  
  
  Why Resource Allocation Matters in HIV Programmes
&lt;/h1&gt;

&lt;p&gt;HIV programmes operate in environments where resources are often limited.&lt;br&gt;
An NGO may have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A limited number of community health workers&lt;/li&gt;
&lt;li&gt;A fixed outreach budget&lt;/li&gt;
&lt;li&gt;Limited HIV testing supplies&lt;/li&gt;
&lt;li&gt;Limited transportation&lt;/li&gt;
&lt;li&gt;Limited clinic staff&lt;/li&gt;
&lt;li&gt;Limited funding for community campaigns&lt;/li&gt;
&lt;li&gt;Limited time for follow-up activities
If these resources are distributed equally across all communities, the approach may appear fair, but it does not necessarily address differences in need.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;blockquote&gt;
&lt;p&gt;Community A may have 90% ART coverage and strong appointment retention, while Community B may have 55% ART coverage and substantial treatment interruptions.&lt;br&gt;
Giving both communities exactly the same level of support may not produce the greatest programme impact.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A data-driven approach asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Where will an additional unit of resources potentially make the greatest difference?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1&gt;
  
  
  What Data Can Be Used?
&lt;/h1&gt;

&lt;p&gt;Before building a machine learning model, an one needs appropriate data.&lt;br&gt;
WHO's HIV strategic information guidance emphasizes the importance of using routine programme data to understand service access, coverage and gaps across the HIV prevention, testing and treatment cascade.&lt;/p&gt;

&lt;p&gt;Potential community-level variables could include:&lt;/p&gt;
&lt;h3&gt;
  
  
  HIV Prevention
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;HIV prevention service coverage&lt;/li&gt;
&lt;li&gt;PrEP uptake&lt;/li&gt;
&lt;li&gt;Condom distribution&lt;/li&gt;
&lt;li&gt;HIV prevention outreach&lt;/li&gt;
&lt;li&gt;Number of people reached&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  HIV Testing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Number of HIV tests conducted&lt;/li&gt;
&lt;li&gt;HIV testing coverage&lt;/li&gt;
&lt;li&gt;HIV positivity yield&lt;/li&gt;
&lt;li&gt;Testing among priority populations&lt;/li&gt;
&lt;li&gt;HIV self-testing uptake&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  HIV Treatment
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Number of people living with HIV receiving ART&lt;/li&gt;
&lt;li&gt;ART coverage&lt;/li&gt;
&lt;li&gt;Treatment initiation&lt;/li&gt;
&lt;li&gt;Treatment retention&lt;/li&gt;
&lt;li&gt;Treatment interruption&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Viral Load Monitoring
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Viral load testing coverage&lt;/li&gt;
&lt;li&gt;Viral suppression&lt;/li&gt;
&lt;li&gt;Clients overdue for viral load monitoring&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Programme Access
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Distance to health facilities&lt;/li&gt;
&lt;li&gt;Availability of outreach services&lt;/li&gt;
&lt;li&gt;Number of healthcare workers&lt;/li&gt;
&lt;li&gt;Availability of HIV services&lt;/li&gt;
&lt;li&gt;Transport accessibility&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Demographic and Geographic Information
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Population size&lt;/li&gt;
&lt;li&gt;Age distribution&lt;/li&gt;
&lt;li&gt;Gender&lt;/li&gt;
&lt;li&gt;Geographic location&lt;/li&gt;
&lt;li&gt;Population density&lt;/li&gt;
&lt;li&gt;Socioeconomic indicators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose is not to collect every possible variable. The organization should identify variables that are relevant to the programme question and ethically appropriate to use.&lt;/p&gt;
&lt;h1&gt;
  
  
  Turning Programme Data into a Resource Allocation Problem
&lt;/h1&gt;

&lt;p&gt;The first step is to convert the broad question into a measurable problem. Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Which communities need help?"&lt;br&gt;
we could ask:&lt;br&gt;
&lt;strong&gt;"Which communities have the greatest combination of HIV service gaps and unmet programme needs?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We could then create a target variable such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Community Need Level

Low
Medium
High
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The machine learning model will then learn from historical programme data and classify communities into these categories.&lt;br&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;Community A → Low Need
Community B → High Need
Community C → Medium Need
Community D → High Need
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides programme managers with a starting point for prioritization.&lt;/p&gt;

&lt;h1&gt;
  
  
  Using Machine Learning to Identify High-Need Communities
&lt;/h1&gt;

&lt;p&gt;One possible approach is &lt;strong&gt;supervised learning&lt;/strong&gt;.&lt;br&gt;
Suppose the NGO has historical data from 100 communities.&lt;br&gt;
For each community, we know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HIV testing coverage&lt;/li&gt;
&lt;li&gt;ART coverage&lt;/li&gt;
&lt;li&gt;Treatment interruption&lt;/li&gt;
&lt;li&gt;Viral load coverage&lt;/li&gt;
&lt;li&gt;Outreach coverage&lt;/li&gt;
&lt;li&gt;Distance to healthcare services&lt;/li&gt;
&lt;li&gt;Previous programme interventions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Programme experts could define historical need categories based on agreed programme criteria.&lt;br&gt;
The model then learns patterns associated with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;High Need
Medium Need
Low Need
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When new programme data becomes available, the model can estimate the likely need category for each community.&lt;/p&gt;

&lt;h1&gt;
  
  
  An Example
&lt;/h1&gt;

&lt;p&gt;Imagine an NGO has funding for only &lt;strong&gt;10 community outreach campaigns&lt;/strong&gt;, but there are &lt;strong&gt;30 communities&lt;/strong&gt; that could potentially receive them.&lt;br&gt;
A simple approach would be to distribute the campaigns equally.&lt;br&gt;
However, machine learning could help identify communities where programme gaps are greatest.&lt;/p&gt;

&lt;p&gt;Suppose the model produces:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Community&lt;/th&gt;
&lt;th&gt;Predicted Need&lt;/th&gt;
&lt;th&gt;Priority Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;91&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;58&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;87&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;18&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;94&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The programme team could prioritize communities &lt;strong&gt;F, B and D&lt;/strong&gt; for additional assessment and potential intervention.&lt;br&gt;
This does not mean that the model automatically decides where resources go.&lt;br&gt;
Instead, it provides &lt;strong&gt;evidence to support programme managers in making better decisions&lt;/strong&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  An Alternative Approach: Clustering Communities
&lt;/h1&gt;

&lt;p&gt;Machine learning does not always need to predict a known outcome.&lt;br&gt;
An NGO could also use &lt;strong&gt;unsupervised learning&lt;/strong&gt;, particularly clustering. Clustering groups communities that have similar characteristics.&lt;br&gt;
For example, a clustering model could identify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cluster 1
High HIV testing
High ART coverage
Low treatment interruption
Strong outreach

Cluster 2
Low HIV testing
Low ART coverage
High treatment interruption
Limited outreach

Cluster 3
Moderate testing
Moderate ART coverage
Moderate treatment interruption
Moderate outreach
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cluster 2 may become an important focus for further programme investigation.&lt;br&gt;
The organization could then ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What is happening in these communities that is contributing to these service gaps?&lt;/strong&gt;&lt;br&gt;
This is an important point: &lt;strong&gt;machine learning identifies patterns, but programme teams still need to understand the reasons behind those patterns.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1&gt;
  
  
  Creating a Community Priority Score
&lt;/h1&gt;

&lt;p&gt;Another practical approach is to develop a &lt;strong&gt;priority score&lt;/strong&gt;.&lt;br&gt;
For example, an NGO could combine several programme indicators:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Priority Score =
Testing Gap
+ ART Coverage Gap
+ Viral Load Monitoring Gap
+ Treatment Interruption
+ Outreach Gap
+ Access Challenges
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact weighting would need to be agreed upon by programme specialists and validated using local evidence.&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Indicator&lt;/th&gt;
&lt;th&gt;Community A&lt;/th&gt;
&lt;th&gt;Community B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Testing gap&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ART coverage gap&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Viral load gap&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Treatment interruption&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Outreach gap&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Overall priority&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Machine learning could then improve this approach by learning from historical outcomes and identifying which combinations of factors are most strongly associated with poor programme performance.&lt;/p&gt;

&lt;h1&gt;
  
  
  From Prediction to Action
&lt;/h1&gt;

&lt;p&gt;A machine learning model is useful only if its predictions lead to appropriate action.&lt;br&gt;
The process could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Programme Data
       ↓
Data Cleaning
       ↓
Exploratory Data Analysis
       ↓
Machine Learning Model
       ↓
Identify High-Need Communities
       ↓
Validate With Programme Teams
       ↓
Prioritize Resources
       ↓
Implement Intervention
       ↓
Monitor Results
       ↓
Update Model and Strategy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h3&gt;
  
  
  Community B
&lt;/h3&gt;

&lt;p&gt;The model identifies Community B as high priority because of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Low HIV testing coverage&lt;/li&gt;
&lt;li&gt;Low ART coverage&lt;/li&gt;
&lt;li&gt;High treatment interruption&lt;/li&gt;
&lt;li&gt;Limited outreach&lt;/li&gt;
&lt;li&gt;Poor access to health services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The NGO could respond by providing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Additional community outreach&lt;/li&gt;
&lt;li&gt;HIV testing services&lt;/li&gt;
&lt;li&gt;Community health worker follow-up&lt;/li&gt;
&lt;li&gt;Appointment support&lt;/li&gt;
&lt;li&gt;Improved linkage to treatment&lt;/li&gt;
&lt;li&gt;Additional health education&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The organization would then monitor whether these interventions improve programme outcomes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Data Quality Matters
&lt;/h1&gt;

&lt;p&gt;Machine learning cannot solve poor-quality data. Suppose one community reports HIV testing correctly while another community consistently under-reports testing. The model may incorrectly conclude that the second community has a greater need.&lt;/p&gt;

&lt;p&gt;Therefore, before using machine learning for resource allocation, the NGO should assess:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing data&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Incorrect values&lt;/li&gt;
&lt;li&gt;Inconsistent reporting&lt;/li&gt;
&lt;li&gt;Changes in reporting systems&lt;/li&gt;
&lt;li&gt;Differences between facilities&lt;/li&gt;
&lt;li&gt;Data completeness&lt;/li&gt;
&lt;li&gt;Data timeliness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;WHO's recent guidance on HIV surveillance emphasizes the importance of improving the quality, consistency and reliability of routine HIV data so that it can support public health action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Better data leads to more reliable analysis and more defensible decisions.&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Machine Learning Should Not Replace Programme Expertise
&lt;/h1&gt;

&lt;p&gt;One of the biggest mistakes would be to assume:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"The model says Community B is high priority, therefore Community B automatically receives all the resources."&lt;/strong&gt;&lt;br&gt;
That is not how responsible machine learning should work.&lt;br&gt;
The model provides evidence, but programme managers should consider additional information.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;ul&gt;
&lt;li&gt;Is there a recent outbreak or programme change?&lt;/li&gt;
&lt;li&gt;Has the community recently received an intervention?&lt;/li&gt;
&lt;li&gt;Is the data complete?&lt;/li&gt;
&lt;li&gt;Are there local barriers not captured in the dataset?&lt;/li&gt;
&lt;li&gt;Are there vulnerable populations that require attention?&lt;/li&gt;
&lt;li&gt;Is the predicted need clinically or programmatically meaningful?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final decision should combine:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Data + Machine Learning + Programme Expertise + Community Knowledge&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Ethical Considerations
&lt;/h1&gt;

&lt;p&gt;HIV data requires strong privacy and confidentiality protections.&lt;br&gt;
WHO guidance emphasizes data security, privacy, confidentiality, appropriate access and governance when using digital and person-centred HIV data.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Protect Confidential Information
&lt;/h2&gt;

&lt;p&gt;Where possible, resource allocation models should work with &lt;strong&gt;aggregated community-level information&lt;/strong&gt; rather than unnecessary individual-level identifiers.&lt;/p&gt;

&lt;p&gt;For example, instead of exposing individual client records:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client ID: 12345
HIV Status: Positive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the resource allocation model may work with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Community: District A
ART Coverage: 62%
Treatment Interruption: 21%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Avoid Bias
&lt;/h2&gt;

&lt;p&gt;A machine learning model can reproduce biases present in historical data. For example, if certain communities have historically received fewer services, the data may make their programme outcomes look different for reasons that are not entirely related to underlying need.&lt;br&gt;
The model should therefore be evaluated carefully across different geographic and population groups.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Do Not Use Predictions to Discriminate
&lt;/h2&gt;

&lt;p&gt;A community being classified as "high need" should lead to &lt;strong&gt;more appropriate support&lt;/strong&gt;, not stigma or punishment.&lt;br&gt;
The purpose should be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Identify gaps → provide support → improve outcomes.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1&gt;
  
  
  Measuring Whether Resources Were Actually Effective
&lt;/h1&gt;

&lt;p&gt;Resource allocation should not stop after resources are distributed.&lt;br&gt;
The NGO should evaluate whether the intervention produced improvement.&lt;br&gt;
For example, before intervention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HIV Testing Coverage = 52%
ART Coverage = 61%
Treatment Interruption = 25%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After six months:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HIV Testing Coverage = 70%
ART Coverage = 74%
Treatment Interruption = 15%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The organization can then assess whether the intervention appears to have improved programme outcomes.&lt;br&gt;
This creates a feedback loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Predict
  ↓
Prioritize
  ↓
Intervene
  ↓
Measure
  ↓
Learn
  ↓
Improve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where machine learning can become part of a continuous programme improvement cycle.&lt;/p&gt;

&lt;h1&gt;
  
  
  How This Helps an NGO Make Better Decisions
&lt;/h1&gt;

&lt;p&gt;Without data-driven prioritization, a programme manager may ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Where should we send our outreach team next month?"&lt;br&gt;
With machine learning and programme data, the question becomes:&lt;br&gt;
"Which communities currently show the greatest combination of service gaps, access challenges and unmet need, and what intervention is most appropriate for each community?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is a much stronger decision-making process.&lt;br&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;Limited Resources
       ↓
Identify Programme Gaps
       ↓
Use Historical Data
       ↓
Apply Machine Learning
       ↓
Rank/Group Communities
       ↓
Validate Results
       ↓
Prioritize High-Need Areas
       ↓
Deploy Resources
       ↓
Measure Impact
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach helps an NGO move from &lt;strong&gt;equal distribution of resources&lt;/strong&gt; to &lt;strong&gt;evidence-informed prioritization based on need and potential programme impact&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Important Limitations
&lt;/h1&gt;

&lt;p&gt;Machine learning is powerful, but it is not a perfect solution.&lt;br&gt;
A model may fail because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data is incomplete&lt;/li&gt;
&lt;li&gt;Historical patterns change&lt;/li&gt;
&lt;li&gt;Some important factors are not recorded&lt;/li&gt;
&lt;li&gt;The model is biased&lt;/li&gt;
&lt;li&gt;Communities differ in ways not captured by the dataset&lt;/li&gt;
&lt;li&gt;Programme priorities change&lt;/li&gt;
&lt;li&gt;Predictions may not translate into real-world impact&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore, machine learning should be treated as a &lt;strong&gt;decision-support tool&lt;/strong&gt;, not an automatic resource allocation system.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;World Health Organization (WHO).&lt;/strong&gt; (2022). &lt;em&gt;Consolidated guidelines on person-centred HIV strategic information: Strengthening routine data for impact.&lt;/em&gt; WHO. The guidelines emphasize using routine data to identify service gaps and improve HIV programme decision-making.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;World Health Organization (WHO).&lt;/strong&gt; (2020). &lt;em&gt;Consolidated HIV strategic information guidelines: Driving impact through programme monitoring and management.&lt;/em&gt; WHO. The guidance highlights the importance of collecting, analysing and using data to identify gaps in HIV service access, coverage and quality.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;UNAIDS.&lt;/strong&gt; (2026). &lt;em&gt;Resource Needs Estimation Tool.&lt;/em&gt; UNAIDS. The tool demonstrates how data-driven resource estimation can support HIV programme planning and allocation across prevention, testing, treatment and other programme areas.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>analytics</category>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Regression Isn’t Regularization: A Simple Guide to Understanding Both</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Mon, 27 Jul 2026 06:44:11 +0000</pubDate>
      <link>https://dev.to/nelima/regression-isnt-regularization-a-simple-guide-to-understanding-both-455b</link>
      <guid>https://dev.to/nelima/regression-isnt-regularization-a-simple-guide-to-understanding-both-455b</guid>
      <description>&lt;p&gt;Regression and regularization are both important concepts in machine learning and statistics, but they solve different problems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Regression&lt;/strong&gt; is primarily used to model relationships and make predictions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regularization&lt;/strong&gt; is used to improve a model's ability to generalize by controlling its complexity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Regression
&lt;/h2&gt;

&lt;p&gt;This is a statistical and machine learning technique used to predict a &lt;strong&gt;continuous numerical outcome&lt;/strong&gt; based on one or more input variables.&lt;br&gt;
For example, we might want to predict:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A house's price based on its size and location&lt;/li&gt;
&lt;li&gt;A student's exam score based on study hours&lt;/li&gt;
&lt;li&gt;A company's sales based on advertising spending&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Simple Linear Regression
&lt;/h3&gt;

&lt;p&gt;In simple linear regression, we model the relationship between an input variable (x) and an output (y):&lt;br&gt;
$$&lt;br&gt;
y = \beta_0 + \beta_1x + \epsilon&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(y) is the predicted outcome&lt;/li&gt;
&lt;li&gt;(\beta_0) is the intercept&lt;/li&gt;
&lt;li&gt;(\beta_1) is the coefficient or slope&lt;/li&gt;
&lt;li&gt;(x) is the input variable&lt;/li&gt;
&lt;li&gt;(\epsilon) represents the error
The model learns values for (\beta_0) and (\beta_1) that make its predictions as close as possible to the actual values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Multiple Linear Regression
&lt;/h3&gt;

&lt;p&gt;In multiple linear regression, several predictors are used:&lt;br&gt;
$$&lt;br&gt;
y = \beta_0 + \beta_1x_1 + \beta_2x_2 + \cdots + \beta_px_p + \epsilon&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The goal is typically to minimize the &lt;strong&gt;sum of squared errors (SSE)&lt;/strong&gt;:&lt;br&gt;
$$&lt;br&gt;
\text{SSE} = \sum_{i=1}^{n}(y_i - \hat{y}_i)^2&lt;br&gt;
$$&lt;br&gt;
This approach is known as &lt;strong&gt;Ordinary Least Squares (OLS)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Regularization
&lt;/h2&gt;

&lt;p&gt;Regularization is a technique used to prevent a machine learning model from becoming too complex.&lt;br&gt;
A model can perform extremely well on training data but poorly on new, unseen data. This problem is called &lt;strong&gt;overfitting&lt;/strong&gt;.&lt;br&gt;
Regularization addresses overfitting by adding a penalty for large model coefficients to the model's objective function.&lt;/p&gt;

&lt;p&gt;Instead of minimizing only the prediction error, the model minimizes:&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;\text{Prediction Error} + \text{Complexity Penalty}&lt;br&gt;
$$&lt;br&gt;
The penalty discourages the model from relying too heavily on individual features.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Main Types of Regularization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Ridge Regression: L2 Regularization
&lt;/h3&gt;

&lt;p&gt;Ridge regression adds a penalty based on the squared values of the coefficients:&lt;br&gt;
$$&lt;/p&gt;

&lt;h1&gt;
  
  
  \text{Loss}
&lt;/h1&gt;

&lt;p&gt;\sum_{i=1}^{n}(y_i - \hat{y}&lt;em&gt;i)^2&lt;br&gt;
+&lt;br&gt;
\lambda\sum&lt;/em&gt;{j=1}^{p}\beta_j^2&lt;br&gt;
$$&lt;br&gt;
Here, (\lambda) controls the strength of the regularization.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If (\lambda = 0), the model is equivalent to ordinary linear regression.&lt;/li&gt;
&lt;li&gt;A larger (\lambda) creates a stronger penalty.&lt;/li&gt;
&lt;li&gt;Coefficients become smaller, but generally do not become exactly zero.
Ridge regression is particularly useful when predictors are highly correlated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Lasso Regression: L1 Regularization
&lt;/h3&gt;

&lt;p&gt;Lasso regression uses the absolute values of the coefficients:&lt;br&gt;
$$&lt;/p&gt;

&lt;h1&gt;
  
  
  \text{Loss}
&lt;/h1&gt;

&lt;p&gt;\sum_{i=1}^{n}(y_i - \hat{y}&lt;em&gt;i)^2&lt;br&gt;
+&lt;br&gt;
\lambda\sum&lt;/em&gt;{j=1}^{p}|\beta_j|&lt;br&gt;
$$&lt;br&gt;
Unlike Ridge regression, Lasso can shrink some coefficients exactly to zero.&lt;/p&gt;

&lt;p&gt;This means Lasso can perform a type of &lt;strong&gt;feature selection&lt;/strong&gt; by effectively removing less important variables from the model.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Elastic Net
&lt;/h3&gt;

&lt;p&gt;Elastic Net combines both L1 and L2 regularization:&lt;br&gt;
$$&lt;/p&gt;

&lt;h1&gt;
  
  
  \text{Loss}
&lt;/h1&gt;

&lt;p&gt;\text{SSE}&lt;br&gt;
+&lt;br&gt;
\lambda_1\sum_j|\beta_j|&lt;br&gt;
+&lt;br&gt;
\lambda_2\sum_j\beta_j^2&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;It combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lasso's ability to perform feature selection&lt;/li&gt;
&lt;li&gt;Ridge's ability to handle correlated features&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Difference Between Regression and Regularization
&lt;/h2&gt;

&lt;p&gt;The simplest way to understand the difference is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Regression builds a model to explain or predict an outcome. Regularization modifies the learning process to control the model's complexity.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, ordinary linear regression might optimize the following objective:&lt;br&gt;
$$&lt;br&gt;
\min_{\beta} \text{SSE}&lt;br&gt;
$$&lt;br&gt;
Ridge regression changes it to:&lt;br&gt;
$$&lt;br&gt;
\min_{\beta}&lt;br&gt;
\left(&lt;br&gt;
\text{SSE}&lt;br&gt;
+&lt;br&gt;
\lambda\sum_j\beta_j^2&lt;br&gt;
\right)&lt;br&gt;
$$&lt;br&gt;
The underlying task is still regression. Regularization simply adds a constraint or penalty to make the model less likely to overfit.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Practical Example
&lt;/h2&gt;

&lt;p&gt;Imagine you are predicting house prices using 100 features, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Square footage&lt;/li&gt;
&lt;li&gt;Number of bedrooms&lt;/li&gt;
&lt;li&gt;Location&lt;/li&gt;
&lt;li&gt;Age of the house&lt;/li&gt;
&lt;li&gt;Distance to schools&lt;/li&gt;
&lt;li&gt;Various highly correlated measurements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An ordinary regression model may fit the training data very closely. However, if there are too many features or strong correlations between them, the model may overfit.&lt;br&gt;
Regularization can help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ridge regression&lt;/strong&gt; shrinks the coefficients of correlated variables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lasso regression&lt;/strong&gt; may reduce some coefficients to zero.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elastic Net&lt;/strong&gt; combines both strategies.
As a result, the model may perform better on new, unseen houses.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Comparison Table
&lt;/h2&gt;

&lt;p&gt;Here is the corrected and clearly formatted Markdown table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Ordinary Regression&lt;/th&gt;
&lt;th&gt;Regularized Regression&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Main purpose&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Model relationships and make predictions&lt;/td&gt;
&lt;td&gt;Reduce overfitting and control complexity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Objective&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Minimize prediction error&lt;/td&gt;
&lt;td&gt;Minimize prediction error plus a penalty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Coefficients&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can become very large&lt;/td&gt;
&lt;td&gt;Penalized and typically smaller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Feature selection&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Usually no&lt;/td&gt;
&lt;td&gt;Lasso can select features&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Handles multicollinearity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can be sensitive&lt;/td&gt;
&lt;td&gt;Ridge handles it well&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Generalization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;May overfit&lt;/td&gt;
&lt;td&gt;Often improves performance on unseen data&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Bias-Variance Tradeoff
&lt;/h2&gt;

&lt;p&gt;Regularization works by introducing a small amount of &lt;strong&gt;bias&lt;/strong&gt; in exchange for reducing &lt;strong&gt;variance&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  An Unregularized Model May Have:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Low training error&lt;/li&gt;
&lt;li&gt;High variance&lt;/li&gt;
&lt;li&gt;Poor performance on new data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A Strongly Regularized Model May Have:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Higher training error&lt;/li&gt;
&lt;li&gt;Lower variance&lt;/li&gt;
&lt;li&gt;Better generalization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to find the right balance.&lt;br&gt;
The regularization parameter (\lambda) is commonly selected using &lt;strong&gt;cross-validation&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Practical Note: Feature Scaling
&lt;/h2&gt;

&lt;p&gt;Regularization is sensitive to the scale of features.&lt;br&gt;
For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Age might range from 0 to 100.&lt;/li&gt;
&lt;li&gt;Income might range from $20,000 to $200,000.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because regularization penalizes coefficient sizes, variables with different scales can be treated unfairly. Therefore, features are often standardized before applying &lt;strong&gt;Ridge, Lasso, or Elastic Net&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;Regression and regularization are not competing concepts.&lt;br&gt;
&lt;strong&gt;Regression&lt;/strong&gt; answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;How can we model the relationship between inputs and a numerical outcome?&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Regularization&lt;/strong&gt; answers:&lt;br&gt;
&lt;em&gt;How can we prevent that model from becoming unnecessarily complex and overfitting the training data?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ordinary linear regression focuses on minimizing prediction error. Regularized regression adds a penalty that discourages overly large coefficients. Ridge, Lasso, and Elastic Net are common examples of regularized regression techniques.&lt;/p&gt;

&lt;p&gt;A useful way to remember the distinction is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Regression learns the relationship. Regularization controls the complexity of what is learned.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Why Statistics is the Secret Weapon Behind Data Science- Healthcare analytics</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Fri, 19 Jun 2026 08:05:14 +0000</pubDate>
      <link>https://dev.to/nelima/why-statistics-is-the-secret-weapon-behind-data-science-healthcare-analytics-1mfa</link>
      <guid>https://dev.to/nelima/why-statistics-is-the-secret-weapon-behind-data-science-healthcare-analytics-1mfa</guid>
      <description>&lt;p&gt;&lt;em&gt;"Without statistics, data is just a collection of numbers. With statistics, data becomes knowledge."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When many people first hear the word &lt;em&gt;statistics&lt;/em&gt;, they imagine complicated formulas, endless calculations, and confusing graphs. It often feels like a subject reserved for mathematicians and researchers. However, after exploring the world of data science, one thing becomes clear: statistics is not just important, it is the foundation upon which data science is built.&lt;/p&gt;

&lt;p&gt;For instance, a healthcare organization that serves thousands of patients every day. Every hospital visit, laboratory test, prescription, and diagnosis generates data. By the end of a single month, the organization may have collected millions of records. While this data is valuable, it is useless unless someone can extract meaningful insights from it. This is where statistics steps in.&lt;/p&gt;

&lt;p&gt;Lindah is a data scientist working for a large healthcare organization. The hospital has noticed an increase in patient readmissions(patients who return to the hospital within 30 days after being discharged). These readmissions are costly for both the hospital and the patients, so management wants to understand why they are happening.&lt;/p&gt;

&lt;p&gt;Lindah is given access to patient data that includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Age&lt;/li&gt;
&lt;li&gt;Medical history&lt;/li&gt;
&lt;li&gt;Length of hospital stay&lt;/li&gt;
&lt;li&gt;Medications prescribed&lt;/li&gt;
&lt;li&gt;Number of previous admissions&lt;/li&gt;
&lt;li&gt;Recovery outcomes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At first glance, the dataset looks overwhelming. Thousands of rows and dozens of columns contain information that appears impossible to interpret manually. Instead of guessing, Lindah turns to statistics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding Patterns Through Descriptive Statistics
&lt;/h2&gt;

&lt;p&gt;Her first step is to summarize the data using descriptive statistics. She calculates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Average patient age&lt;/li&gt;
&lt;li&gt;Average hospital stay duration&lt;/li&gt;
&lt;li&gt;Most common medical conditions&lt;/li&gt;
&lt;li&gt;Readmission rates by age group&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These simple statistical measures immediately reveal interesting patterns. She discovers that patients above the age of 65 have significantly higher readmission rates than younger patients.&lt;br&gt;
Without statistics, this important trend might remain hidden inside thousands of records.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Probability to Predict Risk
&lt;/h2&gt;

&lt;p&gt;The next question is even more important:&lt;br&gt;
&lt;em&gt;"Can we predict which patients are likely to return to the hospital?"&lt;/em&gt;&lt;br&gt;
Lindah uses statistical probability techniques to estimate the likelihood of readmission for different patient groups.&lt;br&gt;
For example, she finds that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Patients with diabetes have a higher probability of returning within 30 days.&lt;/li&gt;
&lt;li&gt;Patients prescribed multiple medications are at greater risk.&lt;/li&gt;
&lt;li&gt;Patients with previous admissions are more likely to be readmitted again.
These probabilities help healthcare providers identify high-risk patients before they leave the hospital.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testing Assumptions with Statistical Analysis
&lt;/h2&gt;

&lt;p&gt;Hospital administrators believe that extending discharge counseling sessions will reduce readmissions.&lt;br&gt;
But is that actually true?&lt;br&gt;
Rather than relying on opinions, Lindah conducts a statistical study that compares two groups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Patients who received standard discharge instructions.&lt;/li&gt;
&lt;li&gt;Patients who received extended counseling and follow-up support.
Using statistical hypothesis testing, she determines whether the observed difference in readmission rates is significant or simply due to chance.
The results show that patients receiving additional counseling are 18% less likely to return to the hospital. This evidence allows hospital leadership to confidently invest in improved discharge programs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Building Predictive Models
&lt;/h2&gt;

&lt;p&gt;Statistics also powers machine learning models.&lt;br&gt;
Using historical patient data, Lindah develops a predictive model that identifies patients at high risk of readmission before they are discharged. The model analyzes numerous factors simultaneously and produces a risk score for each patient.&lt;/p&gt;

&lt;p&gt;Doctors and nurses can then:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Schedule additional follow-up appointments.&lt;/li&gt;
&lt;li&gt;Provide extra education about medications.&lt;/li&gt;
&lt;li&gt;Arrange home healthcare services.&lt;/li&gt;
&lt;li&gt;Monitor high-risk patients more closely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a result, patient outcomes improve and healthcare costs decrease.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Statistics Matters in Data Science
&lt;/h2&gt;

&lt;p&gt;Lindah's story demonstrates a powerful truth: statistics transforms raw data into actionable insights.&lt;br&gt;
In data science, statistics helps professionals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Summarize large datasets.&lt;/li&gt;
&lt;li&gt;Discover hidden patterns.&lt;/li&gt;
&lt;li&gt;Measure uncertainty.&lt;/li&gt;
&lt;li&gt;Test hypotheses.&lt;/li&gt;
&lt;li&gt;Make predictions.&lt;/li&gt;
&lt;li&gt;Support evidence-based decision-making.
Whether in healthcare, banking, retail, education, or technology, every successful data science project relies on statistical thinking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Data science is often associated with programming languages, machine learning, and artificial intelligence. Yet beneath all these advanced technologies lies statistics—the discipline that gives meaning to data.&lt;br&gt;
For a healthcare data scientist like Lindah, statistics is more than a classroom subject. It is a tool that helps hospitals reduce readmissions, improve patient care, and save lives.&lt;/p&gt;

&lt;p&gt;The next time statistics seems intimidating, remember that behind every life-saving healthcare prediction, every accurate forecast, and every data-driven decision, statistics is quietly doing the heavy lifting. It is not merely a part of data science, it is the language that allows data science to speak.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>analytics</category>
      <category>healthcare</category>
    </item>
    <item>
      <title>Python and Its Role in Data Analytics: A Beginner-Friendly Guide Using Logistics Data</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Sun, 10 May 2026 11:01:00 +0000</pubDate>
      <link>https://dev.to/nelima/python-and-its-role-in-data-analytics-a-beginner-friendly-guide-using-logistics-data-591a</link>
      <guid>https://dev.to/nelima/python-and-its-role-in-data-analytics-a-beginner-friendly-guide-using-logistics-data-591a</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In today’s digital economy, organizations generate huge amounts of data every single day. However, raw data alone is not useful unless businesses can analyze it and turn it into meaningful insights.&lt;/p&gt;

&lt;p&gt;One of the most powerful tools used in data analytics today is Python. Python has become one of the most popular programming languages in the world because it is simple, powerful, flexible, and beginner-friendly.&lt;/p&gt;

&lt;p&gt;Unlike some programming languages that are difficult for beginners to understand, Python uses readable syntax that looks almost like normal English. &lt;/p&gt;

&lt;h1&gt;
  
  
  What Is Python?
&lt;/h1&gt;

&lt;p&gt;Python is a high-level programming language created by Guido van Rossum and released in 1991. It was designed to be simple, readable, and easy to learn.&lt;/p&gt;

&lt;p&gt;A high-level language means programmers can write code using human-friendly commands instead of complicated machine instructions.&lt;/p&gt;

&lt;p&gt;For example, displaying a message in Python only requires one line of code:&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello world&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;This simplicity is one of the main reasons Python is popular among beginners.&lt;/p&gt;

&lt;p&gt;Python is also versatile. It can be used in many industries and fields such as: Data analytics, Data science, Artificial intelligence, Machine learning, Web development, Cybersecurity&lt;br&gt;
and Software development&lt;/p&gt;
&lt;h1&gt;
  
  
  Why Python Is Popular in Data Analytics
&lt;/h1&gt;

&lt;p&gt;Python has become one of the most widely used tools in the data analytics space for several reasons.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Python Is Easy to Learn
&lt;/h2&gt;

&lt;p&gt;Python syntax is clean and readable.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Adult&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Minor&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;Even beginners can understand what this code is doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Python Has Powerful Data Libraries
&lt;/h2&gt;

&lt;p&gt;Python has many built-in libraries and external packages that make data analysis easier.&lt;/p&gt;

&lt;p&gt;Instead of writing long and complicated code, analysts can use specialized libraries to complete tasks quickly.&lt;/p&gt;

&lt;p&gt;Popular libraries include: Pandas, NumPy, Matplotlib, Seaborn and Scikit-learn&lt;br&gt;
&lt;strong&gt;These libraries help analysts to:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean data&lt;/li&gt;
&lt;li&gt;Analyze data&lt;/li&gt;
&lt;li&gt;Create charts&lt;/li&gt;
&lt;li&gt;Perform calculations&lt;/li&gt;
&lt;li&gt;Build predictive models&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  3. Python Has a Large Community
&lt;/h2&gt;

&lt;p&gt;Millions of people use Python worldwide. This means beginners can easily find: Tutorials, Documentation, YouTube videos, Coding forums and Online courses -If a beginner encounters an error, there is a high chance someone else has already solved the same problem online.&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Python Handles Large Amounts of Data
&lt;/h2&gt;

&lt;p&gt;Businesses often work with thousands or millions of rows of data.&lt;br&gt;
Python can process large datasets efficiently and integrate with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQL databases&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;Excel files&lt;/li&gt;
&lt;li&gt;Cloud platforms&lt;/li&gt;
&lt;li&gt;Machine learning tools
This makes Python valuable in modern organizations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Python Libraries Used in Data Analytics
&lt;/h1&gt;

&lt;p&gt;Python libraries are collections of pre-written code that help developers complete tasks faster.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Pandas
&lt;/h2&gt;

&lt;p&gt;Pandas is one of the most important Python libraries for data analytics. It is mainly used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading data&lt;/li&gt;
&lt;li&gt;Cleaning data&lt;/li&gt;
&lt;li&gt;Filtering records&lt;/li&gt;
&lt;li&gt;Grouping information&lt;/li&gt;
&lt;li&gt;Performing calculations&lt;/li&gt;
&lt;li&gt;Working with tables&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Example: Loading a Logistics Dataset
&lt;/h3&gt;

&lt;p&gt;Below is an example of loading the logistics dataset using Pandas.&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="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://raw.githubusercontent.com/NelimaL/LOGISTICS_DATA/refs/heads/main/LOGISTICS_MOCK_DATA%20(1).json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&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="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Display first 5 rows by slicing
&lt;/h1&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;logistics_df&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code imports the logistics dataset and displays the first five rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. NumPy
&lt;/h2&gt;

&lt;p&gt;NumPy is used for numerical operations and mathematical calculations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Calculating Average Delivery Time
&lt;/h3&gt;



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

&lt;span class="n"&gt;delivery_times&lt;/span&gt; &lt;span class="o"&gt;=&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="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;average_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delivery_times&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Average Delivery Time:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;average_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Average&lt;/span&gt; &lt;span class="n"&gt;Delivery&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;9.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Matplotlib
&lt;/h2&gt;

&lt;p&gt;Matplotlib is used for creating charts and graphs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Visualizing Delivery Ratings
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="n"&gt;ratings&lt;/span&gt; &lt;span class="o"&gt;=&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;5&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="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ratings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delivery Ratings&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ratings&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Frequency&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a histogram showing how delivery ratings are distributed.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Seaborn
&lt;/h2&gt;

&lt;p&gt;Seaborn is another visualization library that creates more attractive statistical charts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Delivery Time vs Package Weight
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scatterplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;package_weight&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_time&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="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Package Weight vs Delivery Time&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This chart helps analysts determine whether heavier packages take longer to deliver.&lt;/p&gt;

&lt;h1&gt;
  
  
  How Python Is Used to Clean Data
&lt;/h1&gt;

&lt;p&gt;Real-world datasets are rarely perfect.&lt;br&gt;
Data often contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing values&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Incorrect formats&lt;/li&gt;
&lt;li&gt;Typing errors&lt;/li&gt;
&lt;li&gt;Invalid values
Data cleaning is one of the most important steps in analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Checking for Missing Values
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Check missing values
&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;logistics_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isnull&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This code checks how many missing values exist in each column.&lt;/p&gt;
&lt;h2&gt;
  
  
  Removing Duplicate Records
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Remove duplicates
&lt;/span&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop_duplicates&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Duplicates removed&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;Duplicate records can affect business reports and calculations.&lt;/p&gt;
&lt;h2&gt;
  
  
  Converting Date Columns
&lt;/h2&gt;

&lt;p&gt;Dates are very important in analytics.&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="c1"&gt;# Convert dates
&lt;/span&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_date&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&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;to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_date&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pickup_date&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&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;to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pickup_date&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;This converts the columns into proper date format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking Data Types
&lt;/h2&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;logistics_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtypes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding data types helps analysts know which operations can be performed.&lt;/p&gt;

&lt;h1&gt;
  
  
  How Python Is Used to Analyze Data
&lt;/h1&gt;

&lt;p&gt;Once data is cleaned, analysts can start extracting insights.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 1: Counting Delivery Statuses
&lt;/h1&gt;

&lt;p&gt;A logistics company may want to know how many deliveries were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Delivered&lt;/li&gt;
&lt;li&gt;Returned&lt;/li&gt;
&lt;li&gt;In Transit&lt;/li&gt;
&lt;li&gt;Out for Delivery
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;status_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;value_counts&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;status_count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example Output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Delivered&lt;/span&gt;           &lt;span class="mi"&gt;6&lt;/span&gt;
&lt;span class="n"&gt;Returned&lt;/span&gt;            &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;In&lt;/span&gt; &lt;span class="n"&gt;Transit&lt;/span&gt;          &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;Out&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;Delivery&lt;/span&gt;    &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps management monitor operational performance.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 2: Average Delivery Rating
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;average_rating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_rating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Average Delivery Rating:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;average_rating&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example Output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Average&lt;/span&gt; &lt;span class="n"&gt;Delivery&lt;/span&gt; &lt;span class="n"&gt;Rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;3.4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps companies evaluate customer satisfaction.&lt;/p&gt;




&lt;h1&gt;
  
  
  Example 3: Finding the Fastest Deliveries
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;fastest_delivery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_time&lt;/span&gt;&lt;span class="sh"&gt;"&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;fastest_delivery&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tracking_number&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;delivery_time&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]].&lt;/span&gt;&lt;span class="nf"&gt;head&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This identifies packages delivered in the shortest time.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 4: Analyzing Delivery Companies
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;company_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_company&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;value_counts&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;company_count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows how many deliveries each company handled.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 5: Average Package Weight
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;average_weight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;package_weight&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Average Package Weight:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;average_weight&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps logistics companies understand shipment trends.&lt;/p&gt;

&lt;h1&gt;
  
  
  How Python Is Used to Visualize Data
&lt;/h1&gt;

&lt;p&gt;Data visualization helps analysts communicate findings clearly.&lt;/p&gt;

&lt;p&gt;Instead of reading large tables, decision-makers can quickly understand charts and graphs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 1: Bar Chart of Delivery Status
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;status_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;value_counts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;status_count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bar&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delivery Status Distribution&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delivery Status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This chart shows the number of packages in each delivery status.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 2: Pie Chart of Delivery Ratings
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;rating_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_rating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;value_counts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;rating_count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pie&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;autopct&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%1.1f%%&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delivery Ratings&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This chart helps visualize customer satisfaction levels.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 3: Line Graph of Delivery Time
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_time&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;line&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delivery Time Trend&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Shipment Number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delivery Time&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This graph helps analysts identify delivery trends.&lt;/p&gt;

&lt;h1&gt;
  
  
  Real-World Uses of Python in Data Analytics
&lt;/h1&gt;

&lt;p&gt;Python is used in many industries worldwide.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Logistics and Supply Chain
&lt;/h1&gt;

&lt;p&gt;Logistics companies use Python to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Track deliveries&lt;/li&gt;
&lt;li&gt;Optimize delivery routes&lt;/li&gt;
&lt;li&gt;Predict delays&lt;/li&gt;
&lt;li&gt;Analyze delivery performance&lt;/li&gt;
&lt;li&gt;Monitor customer satisfaction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the logistics dataset, analysts can identify common delivery failure reasons.&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;failure_reason&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logistics_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;delivery_failure_reason&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;value_counts&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;failure_reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps companies reduce failed deliveries.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Banking Industry
&lt;/h1&gt;

&lt;p&gt;Banks use Python for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fraud detection&lt;/li&gt;
&lt;li&gt;Credit scoring&lt;/li&gt;
&lt;li&gt;Customer analysis&lt;/li&gt;
&lt;li&gt;Financial forecasting&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;transactions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;transactions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10000&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Suspicious transaction:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  3. Healthcare Industry
&lt;/h1&gt;

&lt;p&gt;Hospitals use Python to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyze patient records&lt;/li&gt;
&lt;li&gt;Predict diseases&lt;/li&gt;
&lt;li&gt;Monitor patient recovery&lt;/li&gt;
&lt;li&gt;Manage hospital operations&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="o"&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;John&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;James&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;patient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pressure&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pressure&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;140&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;patient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;has high blood pressure&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;h1&gt;
  
  
  4. Retail Industry
&lt;/h1&gt;

&lt;p&gt;Retail businesses use Python to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyze customer purchases&lt;/li&gt;
&lt;li&gt;Predict sales trends&lt;/li&gt;
&lt;li&gt;Manage inventory&lt;/li&gt;
&lt;li&gt;Recommend products
Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&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;Milk&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;Bread&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;Milk&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;Eggs&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;Milk&lt;/span&gt;&lt;span class="sh"&gt;"&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;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Milk&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;h2&gt;
  
  
  To manageinventory
&lt;/h2&gt;

&lt;h1&gt;
  
  
  Why Beginners Should Learn Python
&lt;/h1&gt;

&lt;p&gt;There are many reasons beginners should consider learning Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Python Is Beginner-Friendly
&lt;/h2&gt;

&lt;p&gt;Python has simple syntax that makes programming easier to understand. Beginners can focus on solving problems instead of struggling with complicated rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Python Is Highly Marketable
&lt;/h2&gt;

&lt;p&gt;Python skills are highly demanded in industries such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data analytics&lt;/li&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;li&gt;Software engineering&lt;/li&gt;
&lt;li&gt;Cybersecurity&lt;/li&gt;
&lt;li&gt;Data science
Professionals with Python skills often have strong career opportunities.
## 3. Python Supports Automation
Python can automate repetitive tasks which saves time and increases efficiency.
Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&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;6&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Generating Report&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Python Encourages Problem Solving
&lt;/h2&gt;

&lt;p&gt;Learning Python improves logical thinking and problem-solving skills. This skill is valuable in many careers.&lt;/p&gt;

&lt;h1&gt;
  
  
  Challenges Beginners May Face
&lt;/h1&gt;

&lt;p&gt;Although Python is beginner-friendly, learners may still experience challenges.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding Programming Logic
&lt;/h2&gt;

&lt;p&gt;Programming requires critical thinking and logical reasoning.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Learning Libraries
&lt;/h2&gt;

&lt;p&gt;Libraries such as Pandas and NumPy can feel overwhelming at first.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Debugging Errors
&lt;/h2&gt;

&lt;p&gt;Beginners often encounter syntax errors.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The closing bracket is missing.&lt;br&gt;
However, with practice, debugging becomes easier.&lt;/p&gt;

&lt;h1&gt;
  
  
  Tips for Learning Python Successfully
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Practice Regularly
&lt;/h2&gt;

&lt;p&gt;The more you practice, the more comfortable you become.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Real Projects
&lt;/h2&gt;

&lt;p&gt;Projects help beginners apply what they learn.&lt;br&gt;
Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Delivery tracking dashboards&lt;/li&gt;
&lt;li&gt;Sales analysis projects&lt;/li&gt;
&lt;li&gt;Expense trackers&lt;/li&gt;
&lt;li&gt;Student performance analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learn Data Visualization
&lt;/h2&gt;

&lt;p&gt;Visualization is one of the most valuable skills in analytics.&lt;br&gt;
Practice creating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bar charts&lt;/li&gt;
&lt;li&gt;Pie charts&lt;/li&gt;
&lt;li&gt;Histograms&lt;/li&gt;
&lt;li&gt;Scatter plots&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Read Error Messages Carefully
&lt;/h2&gt;

&lt;p&gt;Python error messages usually explain the problem. Understanding these messages helps learners improve faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Real Data
&lt;/h2&gt;

&lt;p&gt;Working with real datasets improves learning.&lt;br&gt;
The logistics dataset used in this article demonstrates how businesses analyze operational data using Python.&lt;/p&gt;

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

&lt;p&gt;As businesses continue generating larger amounts of data, the demand for Python skills will continue growing. Beginners who start learning Python today are preparing themselves for exciting opportunities in the future of data analytics.&lt;/p&gt;

</description>
      <category>python</category>
      <category>datascience</category>
    </item>
    <item>
      <title>SQL Without Confusion: Subqueries vs CTEs (Visual + Practical Guide)</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Wed, 22 Apr 2026 09:07:36 +0000</pubDate>
      <link>https://dev.to/nelima/sql-without-confusion-subqueries-vs-ctes-visual-practical-guide-3l5m</link>
      <guid>https://dev.to/nelima/sql-without-confusion-subqueries-vs-ctes-visual-practical-guide-3l5m</guid>
      <description>&lt;p&gt;Understanding subqueries and CTEs (Common Table Expressions) becomes much easier when you can see how data flows. This guide uses simple diagrams and real-style datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Subquery?&lt;/strong&gt;&lt;br&gt;
A subquery is a query inside another query.&lt;/p&gt;

&lt;p&gt;Visual Representation&lt;br&gt;
Outer Query&lt;br&gt;
   ↓&lt;br&gt;
[ Uses result from ]&lt;br&gt;
   ↓&lt;br&gt;
(Subquery)&lt;/p&gt;

&lt;p&gt;Example: Students scoring above average&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**How it Works&lt;br&gt;
Step 1: Subquery runs&lt;br&gt;
    SELECT AVG(marks) → returns 81.6&lt;/p&gt;

&lt;p&gt;Step 2: Outer query runs&lt;br&gt;
    Returns students with marks &amp;gt; 81.6**&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Subqueries&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Scalar Subquery (Single Value)&lt;/strong&gt;&lt;br&gt;
Returns exactly one value (one row and one column). It is commonly used in SELECT lists or in WHERE clauses with simple comparison operators like = or &amp;gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&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;2. Correlated Subquery (Row-by-Row Execution)&lt;/strong&gt;&lt;br&gt;
Depends on the outer query and executes once for each row in the outer query&lt;br&gt;
FOR each row in outer query:run subquery again&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be slow because it runs multiple times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Multi-row Subquery&lt;/strong&gt;&lt;br&gt;
Returns one or more rows. These usually require set operators such as IN, ANY, or ALL in the outer query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This finds students living in the same cities as patients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a CTE?&lt;/strong&gt;&lt;br&gt;
A CTE is a temporary result set defined using the WITH clause. It improves readability and allows you to reuse query logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Syntax:&lt;/strong&gt;&lt;br&gt;
WITH cte_name AS (&lt;br&gt;
    SELECT column1, column2&lt;br&gt;
    FROM table&lt;br&gt;
)&lt;br&gt;
SELECT * FROM cte_name;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of CTEs&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Simple CTE-Used to simplify complex queries
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;avg_marks&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_score&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;avg_marks&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;avg_score&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;Flow&lt;/strong&gt;&lt;br&gt;
Step 1: avg_marks created&lt;br&gt;
Step 2: Main query uses it&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multiple CTEs-Define more than one CTE in a single query
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;student_marks&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
    &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;
&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="n"&gt;top_students&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;student_marks&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;top_students&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Recursive CTE (Hierarchy)
A CTE that references itself to repeatedly execute a query until a specific condition is met. It consists of an anchor member (initial result) and a recursive member (iterative logic).
Example: Employee hierarchy (Hospital)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="k"&gt;RECURSIVE&lt;/span&gt; &lt;span class="n"&gt;staff_hierarchy&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;full_name&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;
    &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
    &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;staff_hierarchy&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;staff_hierarchy&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;Subqueries vs CTEs&lt;/strong&gt; &lt;br&gt;
Comparison Table&lt;/p&gt;

&lt;h2&gt;
  
  
  📊 Comparison Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Subqueries&lt;/th&gt;
&lt;th&gt;CTEs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Can become hard to read when nested&lt;/td&gt;
&lt;td&gt;Much cleaner and easier to follow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reusability&lt;/td&gt;
&lt;td&gt;Cannot be reused easily&lt;/td&gt;
&lt;td&gt;Can be referenced multiple times&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Faster for simple queries&lt;/td&gt;
&lt;td&gt;Better for complex logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Execution&lt;/td&gt;
&lt;td&gt;Often executed multiple times&lt;/td&gt;
&lt;td&gt;Executed once (in many cases)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debugging&lt;/td&gt;
&lt;td&gt;Harder to debug&lt;/td&gt;
&lt;td&gt;Easier to test step-by-step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recursion&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;When to Use What&lt;/strong&gt;&lt;br&gt;
Use Subqueries When:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The logic is simple and short&lt;/li&gt;
&lt;li&gt;You only need the result once&lt;/li&gt;
&lt;li&gt;You want a quick inline filter
Use CTEs When:&lt;/li&gt;
&lt;li&gt;The query is complex or layered&lt;/li&gt;
&lt;li&gt;You need to reuse logic&lt;/li&gt;
&lt;li&gt;You want cleaner, more maintainable SQL&lt;/li&gt;
&lt;li&gt;You are working with recursive data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
Both subqueries and CTEs are essential tools in SQL. While subqueries are great for quick, simple tasks, CTEs shine when dealing with complex logic and improving readability.&lt;/p&gt;

&lt;p&gt;As a data analyst, knowing when to use each can significantly improve both your query performance and the clarity of your code.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>dataanalytics</category>
      <category>beginners</category>
      <category>database</category>
    </item>
    <item>
      <title>Mastering SQL Joins: A Practical Guide for beginners.</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Tue, 21 Apr 2026 07:23:20 +0000</pubDate>
      <link>https://dev.to/nelima/mastering-sql-joins-a-practical-guide-for-beginners-409j</link>
      <guid>https://dev.to/nelima/mastering-sql-joins-a-practical-guide-for-beginners-409j</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;SQL joins allow you to combine data from multiple tables based on relationships between them. In this article, we’ll explore different types of joins using this two schemas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;City Hospital Schema&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nairobi Academy Schema&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is a SQL Join?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;join&lt;/strong&gt; retrieves data from two or more tables using a related column.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&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;1. INNER JOIN&lt;/strong&gt;&lt;br&gt;
Returns only records that exist in both tables.&lt;/p&gt;

&lt;p&gt;Example (City Hospital schema)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;patient_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;doctor_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;diagnosis&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;doctors&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only matching records appear while missing relationships are excluded&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. LEFT JOIN&lt;/strong&gt;&lt;br&gt;
Returns all records from the left table and matches from the right.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;diagnosis&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All patients are shown while missing appointments appear as NULL&lt;br&gt;
This shows all primary records, even if incomplete&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. RIGHT JOIN&lt;/strong&gt;&lt;br&gt;
Returns all records from the right table.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;diagnosis&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;RIGHT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;doctors&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All doctors appear while missing appointments show NULL&lt;br&gt;
The Focus on the right-side table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. FULL OUTER JOIN&lt;/strong&gt;&lt;br&gt;
Returns all records from both tables, matched or not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_date&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="k"&gt;FULL&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Combines LEFT + RIGHT JOIN behavior&lt;br&gt;
You will see everything, including gaps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. CROSS JOIN&lt;/strong&gt;&lt;br&gt;
Returns all possible combinations.&lt;/p&gt;

&lt;p&gt;Example (Nairobi Academy)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="k"&gt;CROSS&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;exams&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Produces Cartesian product&lt;br&gt;
This Generates combinations&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. SELF JOIN&lt;/strong&gt;&lt;br&gt;
A table joins with itself.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;student_1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;s2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;student_2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;
    &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful for comparisons or hierarchies&lt;br&gt;
This Compares rows within the same table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. LEFT ANTI JOIN (Find Missing Data)&lt;/strong&gt;&lt;br&gt;
Returns records in the left table with no match.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; 
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; 
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This finds missing relationships.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. RIGHT ANTI JOIN&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;doctors&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finds unused or inactive records&lt;/p&gt;

&lt;p&gt;Nairobi Academy: &lt;strong&gt;Combining Data&lt;/strong&gt;&lt;br&gt;
Student Exam Results&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;exams&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_id&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;Ranking Students&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;RANK&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_name&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;exams&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exam_id&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;Here is a shortcut to choosing the Right Join&lt;/strong&gt;&lt;br&gt;
| *&lt;em&gt;Join Type *&lt;/em&gt;      | *&lt;em&gt;When to Use *&lt;/em&gt;         |&lt;br&gt;
| ------------------- | ------------------------ |&lt;br&gt;
| INNER JOIN          | Only matching data       |&lt;br&gt;
| LEFT JOIN           | All left + matches       |&lt;br&gt;
| RIGHT JOIN          | All right + matches      |&lt;br&gt;
| FULL OUTER JOIN     | Everything               |&lt;br&gt;
| CROSS JOIN          | All combinations         |&lt;br&gt;
| SELF JOIN           | Compare within table     |&lt;br&gt;
| ANTI JOIN           | Find missing data        |&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
SQL joins are the foundation of relational data analysis.&lt;br&gt;
Mastering them allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combine datasets effectively&lt;/li&gt;
&lt;li&gt;Identify missing or inconsistent data&lt;/li&gt;
&lt;li&gt;Build powerful reports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The real skill isn’t just writing joins,it’s understanding when to use each one.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Understanding SQL Basics: DDL, DML, Filtering, and Data Transformation</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Sun, 12 Apr 2026 05:30:54 +0000</pubDate>
      <link>https://dev.to/nelima/understanding-sql-basics-ddl-dml-filtering-and-data-transformation-174o</link>
      <guid>https://dev.to/nelima/understanding-sql-basics-ddl-dml-filtering-and-data-transformation-174o</guid>
      <description>&lt;p&gt;This week I was focused on building a solid foundation in SQL by working with student, subject, and exam result data. Along the way, I explored key concepts like DDL, DML, filtering using &lt;code&gt;WHERE&lt;/code&gt;, and transforming data using &lt;code&gt;CASE WHEN&lt;/code&gt;. Here’s a summary of what I learned.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are DDL and DML?
&lt;/h2&gt;

&lt;p&gt;SQL commands are broadly categorized into two main types:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. DDL (Data Definition Language)
&lt;/h3&gt;

&lt;p&gt;DDL is used to define and manage the structure of a database.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CREATE&lt;/code&gt; – used to create tables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ALTER&lt;/code&gt; – used to modify table structure&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DROP&lt;/code&gt; – used to delete tables&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;first_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;last_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;gender&lt;/span&gt; &lt;span class="nb"&gt;CHAR&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="n"&gt;date_of_birth&lt;/span&gt; &lt;span class="nb"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In simple terms, DDL defines how the database looks.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. DML (Data Manipulation Language)
&lt;/h3&gt;

&lt;p&gt;DML is used to manage and manipulate the data inside the tables.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;INSERT – add new data&lt;/li&gt;
&lt;li&gt;UPDATE – modify existing data&lt;/li&gt;
&lt;li&gt;DELETE – remove data&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&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="s1"&gt;'Amina'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Wanjiku'&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;DML focuses on the data itself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;USING CREATE, INSERT, UPDATE, and DELETE&lt;/strong&gt;&lt;br&gt;
I used CREATE to define tables like students, subjects, and exam_results.&lt;br&gt;
I used INSERT to populate tables with records extracted from provided data.&lt;br&gt;
Although not heavily used, UPDATE can be applied to change values, &lt;br&gt;
for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Nairobi'&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="n"&gt;removes&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands helped me understand how databases are built and maintained step by step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filtering Data Using WHERE&lt;/strong&gt;&lt;br&gt;
The WHERE clause is used to filter records based on conditions.&lt;/p&gt;

&lt;p&gt;These are some of operators  used:&lt;br&gt;
= → exact match&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;→ greater than&lt;br&gt;
BETWEEN → range filtering&lt;br&gt;
IN → multiple values&lt;br&gt;
LIKE → pattern matching&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Exact match&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Form 4'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Range&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;exam_results&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="k"&gt;BETWEEN&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Multiple values&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Nairobi'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Mombasa'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Kisumu'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Pattern matching&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="s1"&gt;'A%'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the most powerful parts of SQL because it allows precise data retrieval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transforming Data Using CASE WHEN&lt;/strong&gt;&lt;br&gt;
CASE WHEN allows us to create new columns based on conditions. It works like an "if-else" statement in programming.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;CASE&lt;/span&gt; 
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Distinction'&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Merit'&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Pass'&lt;/span&gt;
        &lt;span class="k"&gt;ELSE&lt;/span&gt; &lt;span class="s1"&gt;'Fail'&lt;/span&gt;
    &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;performance&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;exam_results&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helped convert raw numeric data into meaningful categories.&lt;br&gt;
CASE WHEN is very useful for reporting and data interpretation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reflection&lt;/strong&gt;&lt;br&gt;
This week was both challenging and interesting.&lt;br&gt;
What I found challenging:&lt;br&gt;
Understanding when to use operators like IN vs BETWEEN&lt;br&gt;
Writing clean and error-free queries, most of my queries were to be corrected before running.&lt;/p&gt;

&lt;p&gt;Seeing how raw data can be transformed into meaningful insights on the other hand was very interesting.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
This week helped me understand the basics of working with databases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DDL defines structure&lt;/li&gt;
&lt;li&gt;DML manipulates data&lt;/li&gt;
&lt;li&gt;WHERE filters results&lt;/li&gt;
&lt;li&gt;CASE WHEN transforms data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are essential building blocks for any developer working with databases. I’m looking forward to learning more advanced SQL concepts like joins and aggregations next and I will share it all here.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
    </item>
    <item>
      <title>How to Publish a Power BI Report and Embed it into a Website</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Mon, 06 Apr 2026 12:30:02 +0000</pubDate>
      <link>https://dev.to/nelima/how-to-publish-a-power-bi-report-and-embed-it-into-a-website-341o</link>
      <guid>https://dev.to/nelima/how-to-publish-a-power-bi-report-and-embed-it-into-a-website-341o</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
As s student data plumber, there are very high chances are you've come across Power BI, Microsoft’s powerful business intelligence tool that transforms raw data into meaningful insights through interactive dashboards and reports.&lt;br&gt;
So far, as a data student I’ve explored Power BI queries, DAX, data modeling, joins, charts, dashboards, and reporting. But creating a report is only half the job. The real value comes when you share it with others.&lt;/p&gt;

&lt;p&gt;In this article, I’ll walk you through how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Publish a Power BI report&lt;/li&gt;
&lt;li&gt;Generate an embed code&lt;/li&gt;
&lt;li&gt;Embed the report into a website
By the end, you’ll be able to make your reports accessible and interactive for users beyond Power BI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is Power BI Publishing?&lt;/strong&gt;&lt;br&gt;
Publishing in Power BI means uploading your report from Power BI Desktop (.pbix file) to the Power BI Service (cloud platform). Once published, your report can be shared, collaborated on, or embedded into websites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create a Workspace&lt;/strong&gt;&lt;br&gt;
A workspace is like a container where your reports, dashboards, and datasets live.&lt;br&gt;
&lt;strong&gt;Steps:&lt;/strong&gt;&lt;br&gt;
Go to Power BI Service (&lt;a href="https://app.powerbi.com" rel="noopener noreferrer"&gt;https://app.powerbi.com&lt;/a&gt;)&lt;br&gt;
Sign in with your account&lt;br&gt;
On the left sidebar, click Workspaces&lt;br&gt;
Click + New workspace&lt;br&gt;
Enter: Workspace name(e.g., Linda Nelima  Workspace)&lt;br&gt;
Description (optional)&lt;br&gt;
Click Save&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.amazonaws.com%2Fuploads%2Farticles%2Fxa8ghir7g67026v1qzt8.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.amazonaws.com%2Fuploads%2Farticles%2Fxa8ghir7g67026v1qzt8.png" alt="Workspace screenshot" width="634" height="606"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Upload and Publish Your Report&lt;/strong&gt;&lt;br&gt;
Now that your workspace is ready, let’s upload the .pbix file.&lt;br&gt;
&lt;strong&gt;Steps:&lt;/strong&gt;&lt;br&gt;
Open your project in Power BI Desktop&lt;br&gt;
Click File → Publish → Select Workspace&lt;br&gt;
Choose the workspace you created&lt;br&gt;
Click Select&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.amazonaws.com%2Fuploads%2Farticles%2Fydqaherrixfnm4z55r3j.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.amazonaws.com%2Fuploads%2Farticles%2Fydqaherrixfnm4z55r3j.png" alt="Publish icon" width="800" height="84"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Alternatively (via browser):&lt;/strong&gt;&lt;br&gt;
Open your workspace in Power BI Service&lt;br&gt;
Click Upload → Browse&lt;br&gt;
Upload your .pbix file&lt;br&gt;
Once uploaded, your report and dataset will appear in the created workspace.&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.amazonaws.com%2Fuploads%2Farticles%2Fbrcwznx8hbbl0i2w21f9.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.amazonaws.com%2Fuploads%2Farticles%2Fbrcwznx8hbbl0i2w21f9.png" alt="Pop up message" width="754" height="448"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 3: Generate the Embed Code&lt;/strong&gt;&lt;br&gt;
Power BI allows you to embed reports using an iframe.&lt;br&gt;
&lt;strong&gt;iframe:&lt;/strong&gt;(short for inline frame) is an HTML element that embeds another document, such as a video, map, or webpage, within the current HTML webpage&lt;br&gt;
&lt;strong&gt;Steps:&lt;/strong&gt;&lt;br&gt;
Open your report in Power BI Service&lt;br&gt;
Click File → Embed report → Publish to web (public)&lt;br&gt;
Click Create embed code&lt;br&gt;
Copy the generated iframe code&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Note:“Publish to web” makes your report publicly accessible. Avoid using this for sensitive data.&lt;/em&gt;&lt;/strong&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fil7t9vkt1g4q4pne7trq.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.amazonaws.com%2Fuploads%2Farticles%2Fil7t9vkt1g4q4pne7trq.png" alt="Embeding" width="619" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step 4: Embed the Report on a Website&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Now let’s embed the report into a simple HTML page.&lt;br&gt;
Example:&lt;br&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;br&gt;
    Power BI Report
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
    &lt;h1&gt;Kenya Crops Dashboard&lt;/h1&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;iframe width="800" height="600"
    src="YOUR_EMBED_LINK_HERE"
    frameborder="0"
    allowFullScreen="true"&amp;gt;
&amp;lt;/iframe&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;Steps:&lt;/strong&gt;&lt;br&gt;
Replace YOUR_EMBED_LINK_HERE with your copied embed URL&lt;br&gt;
Save the file as index.html&lt;br&gt;
Open it in a browser&lt;/p&gt;

&lt;p&gt;You should now see your interactive Power BI report embedded on the page. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Power BI&lt;/strong&gt; makes it easy to move from data analysis to sharing insights&lt;br&gt;
&lt;strong&gt;Workspaces&lt;/strong&gt; help organize and manage reports efficiently&lt;br&gt;
&lt;strong&gt;Embedding reports&lt;/strong&gt; allows integration with web apps and dashboards&lt;br&gt;
Always be cautious with data privacy when using public embed options&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>microsoft</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Data Modeling in Power BI: Joins, Relationships, and Schemas Explained</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Mon, 30 Mar 2026 14:40:50 +0000</pubDate>
      <link>https://dev.to/nelima/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-1aee</link>
      <guid>https://dev.to/nelima/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-1aee</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When I first started working with Power BI at LuxedevHQ, I quickly realized that building reports isn’t just about visuals, it’s about how well your data is structured underneath. That structure is called &lt;strong&gt;&lt;em&gt;data modeling&lt;/em&gt;&lt;/strong&gt;, and it’s the backbone of every meaningful dashboard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Data Modeling&lt;/strong&gt;&lt;br&gt;
Data modeling is the process of organizing data into tables and defining how those tables relate to each other so that analysis becomes efficient, accurate, and scalable.                                        In Power BI, data modeling involves:&lt;br&gt;
• Structuring tables (Fact &amp;amp; Dimension) &lt;br&gt;
• Creating relationships &lt;br&gt;
• Defining cardinality and filter behavior &lt;br&gt;
• Optimizing for performance and usability &lt;br&gt;
&lt;strong&gt;&lt;em&gt;Think of it as designing a map before starting a journey. Without it, you’ll get lost in your data.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Joins&lt;/strong&gt;&lt;br&gt;
Before Power BI relationships, you need to understand joins, because they define how tables combine.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Let’s use this simple scenario&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Customers&lt;/strong&gt;&lt;br&gt;
| CustomerID | Name |&lt;br&gt;
|------------|------|&lt;br&gt;
| 1          | John |&lt;br&gt;
| 2          | Mary |&lt;br&gt;
&lt;strong&gt;Orders&lt;/strong&gt;&lt;br&gt;
| OrderID | CustomerID | Amount |&lt;br&gt;
|---------|------------|--------|&lt;br&gt;
| 101     | 1          | 200    |&lt;br&gt;
| 102     | 1          | 150    |&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. INNER JOIN&lt;/strong&gt;&lt;br&gt;
This returns only matching records.&lt;br&gt;
&lt;strong&gt;Result&lt;/strong&gt;&lt;br&gt;
| Name | Amount |&lt;br&gt;
|------|--------|&lt;br&gt;
| John | 200    |&lt;br&gt;
| John | 150    | &lt;br&gt;
&lt;strong&gt;&lt;em&gt;Mary is excluded because she has no orders and this only shows customers who made a purchase&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;2. LEFT JOIN&lt;/strong&gt;&lt;br&gt;
This returns all records from the left table and matches.&lt;br&gt;
&lt;strong&gt;Result&lt;/strong&gt;&lt;br&gt;
| Name | Amount |&lt;br&gt;
|------|--------|&lt;br&gt;
| John | 200    |&lt;br&gt;
| John | 150    |&lt;br&gt;
| Mary | NULL   |&lt;br&gt;
Keeps all customers, even without orders.&lt;br&gt;
&lt;strong&gt;3. RIGHT JOIN&lt;/strong&gt;&lt;br&gt;
This join returns all records from the right table and matches.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Use case:&lt;/em&gt;&lt;/strong&gt; Show all orders, even if customer data is missing.&lt;br&gt;
&lt;strong&gt;4. FULL OUTER JOIN&lt;/strong&gt;&lt;br&gt;
This returns everything from both tables.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Use case:&lt;/em&gt;&lt;/strong&gt;Data reconciliation between systems.&lt;br&gt;
&lt;strong&gt;5. LEFT ANTI JOIN&lt;/strong&gt;&lt;br&gt;
The Left Anti Join returns rows in left table with NO match in right.&lt;br&gt;
&lt;strong&gt;Result&lt;/strong&gt;&lt;br&gt;
| Name |&lt;br&gt;
|------|&lt;br&gt;
| Mary |&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Use case:&lt;/em&gt;&lt;/strong&gt;Customers who never purchased.&lt;br&gt;
&lt;strong&gt;6. RIGHT ANTI JOIN&lt;/strong&gt;&lt;br&gt;
Returns rows in right table with NO match in left.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Use case:&lt;/em&gt;&lt;/strong&gt;Orders with missing customer records.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Create Joins in Power BI&lt;/strong&gt; &lt;br&gt;
In Power Query:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click Transform Data&lt;/li&gt;
&lt;li&gt;Select a table&lt;/li&gt;
&lt;li&gt;Click Merge Queries&lt;/li&gt;
&lt;li&gt;Select second table&lt;/li&gt;
&lt;li&gt;Choose join type:&lt;/li&gt;
&lt;li&gt;  Inner&lt;/li&gt;
&lt;li&gt;  Left Outer

&lt;ul&gt;
&lt;li&gt;Right Outer&lt;/li&gt;
&lt;li&gt;Full Outer&lt;/li&gt;
&lt;li&gt;Left Anti&lt;/li&gt;
&lt;li&gt;Right Anti&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click OK&lt;/li&gt;
&lt;li&gt;Expand columns
This is where SQL joins happen inside Power BI.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Power BI Relationships&lt;/strong&gt;&lt;br&gt;
Unlike joins, relationships don’t merge tables—they connect them.&lt;br&gt;
&lt;strong&gt;Types of Relationships&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. One-to-Many (1:M)&lt;/strong&gt;&lt;br&gt;
This is the Most common and the default best practice.&lt;br&gt;
Here One value in Table A relates to many in Table B.&lt;br&gt;
&lt;strong&gt;Example&lt;br&gt;
One customer → many orders&lt;br&gt;
One product → many sales&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Many-to-Many (M:M)
Both tables have duplicate values.
**Example:
Students ↔ Courses&lt;/li&gt;
&lt;li&gt;A student can take many courses&lt;/li&gt;
&lt;li&gt;A course can have many students**
&lt;strong&gt;&lt;em&gt;Problem:&lt;/em&gt;&lt;/strong&gt;
This can create ambiguous calculations
It is harder to control filtering
&lt;strong&gt;3. One-to-One (1:1)&lt;/strong&gt;
Here each value appears once in both tables.
&lt;strong&gt;Example:
User table ↔ User profile table&lt;/strong&gt;
This is rare in real-world analytics&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Active vs Inactive Relationships&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Active Relationship&lt;/strong&gt; This is a default relationship used automatically&lt;br&gt;
It is represented by a solid line in Model View&lt;br&gt;
&lt;strong&gt;Inactive Relationship&lt;/strong&gt; Exists but is NOT used unless explicitly activated&lt;br&gt;
Represented by a dashed line&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cardinality&lt;/strong&gt;&lt;br&gt;
Cardinality defines the structure of the relationship&lt;br&gt;
Power BI usually auto-detects this, but you should always verify it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-Filter Direction&lt;/strong&gt;&lt;br&gt;
Defines how filters flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single direction: One table filters another&lt;/li&gt;
&lt;li&gt;Both direction: Tables filter each other&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to Create Relationships in Power BI&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Method 1: Model View&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Model View&lt;/li&gt;
&lt;li&gt;Drag one column onto another&lt;/li&gt;
&lt;li&gt;Relationship is automatically created
&lt;strong&gt;Method 2: Manage Relationships&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Go to Home → Manage Relationships&lt;/li&gt;
&lt;li&gt;Click New&lt;/li&gt;
&lt;li&gt;Select:&lt;/li&gt;
&lt;li&gt;Tables&lt;/li&gt;
&lt;li&gt;Columns&lt;/li&gt;
&lt;li&gt;Cardinality&lt;/li&gt;
&lt;li&gt;Cross-filter direction&lt;/li&gt;
&lt;li&gt;Click OK&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Joins vs Relationships (Key Difference)&lt;/strong&gt;&lt;br&gt;
| Feature     | Joins          | Relationships   |&lt;br&gt;
| ----------- | -------------- | --------------- |&lt;br&gt;
| Where used  | Power Query    | Data Model      |&lt;br&gt;
| Output      | Combined table | Separate tables |&lt;br&gt;
| Performance | Heavier        | More efficient  |&lt;br&gt;
| Flexibility | Less           | More            |&lt;br&gt;
&lt;strong&gt;&lt;em&gt;TIP: Use relationships for analysis and joins for data cleaning&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Modeling Schemas&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Star Schema: A central fact table surrounded by denormalized dimension tables, designed for high-performance querying in business intelligence and data warehouses.&lt;br&gt;
&lt;strong&gt;Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Customers&lt;br&gt;
       |&lt;br&gt;
Products — Sales — Date&lt;br&gt;
       |&lt;br&gt;
    Stores&lt;br&gt;
Why it’s great?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fast&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to understand&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Recommended in Power BI&lt;br&gt;
&lt;strong&gt;2. Snowflake Schema&lt;/strong&gt; &lt;br&gt;
An extension of the star schema where dimension tables are normalized into multiple related tables, reducing redundancy but increasing complexity.&lt;br&gt;
Example:&lt;br&gt;
Customer → City → Country&lt;br&gt;
&lt;strong&gt;3. Flat Table (Denormalized / DLAT)&lt;/strong&gt;&lt;br&gt;
Everything is in one table.&lt;br&gt;
Pros: it is simple&lt;br&gt;
Cons: Large in size, Hard to maintain&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Common Data Modeling Issues&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Many-to-Many Confusion, Leads to incorrect totals.&lt;/li&gt;
&lt;li&gt;Circular Relationships: Power BI blocks these, avoid loops.&lt;/li&gt;
&lt;li&gt;Ambiguous Paths: Multiple filter paths lead to wrong calculations.&lt;/li&gt;
&lt;li&gt;Poor Naming: Bad names leads confusion later.&lt;/li&gt;
&lt;li&gt;Overusing “Both” Filters&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Data modeling isn’t just technical, it’s strategic.&lt;br&gt;
When you: Choose the right schema, Use relationships properly and&lt;br&gt;
Understand joins, Your Power BI reports become faster, cleaner, and more reliable.&lt;/em&gt;&lt;/strong&gt;&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>powerbi</category>
      <category>sql</category>
      <category>datamodelling</category>
    </item>
    <item>
      <title>How Excel is Used in Real-World Data Analysis</title>
      <dc:creator>NelimaL</dc:creator>
      <pubDate>Tue, 24 Mar 2026 10:46:33 +0000</pubDate>
      <link>https://dev.to/nelima/how-excel-is-used-in-real-world-data-analysis-4pc2</link>
      <guid>https://dev.to/nelima/how-excel-is-used-in-real-world-data-analysis-4pc2</guid>
      <description>&lt;p&gt;When I first started learning data analytics, I thought tools like Python or advanced software would dominate everything. But I quickly realized something surprising: Microsoft Excel is still one of the most powerful and widely used tools in real-world data analysis. It’s not just a spreadsheet application it’s a practical, flexible, and accessible platform for exploring, cleaning, and interpreting data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, what is Excel?&lt;/strong&gt;&lt;br&gt;
Excel is a spreadsheet tool that lets you organize data into rows and columns, perform calculations, and create visual reports. That sounds simple, but it goes much deeper than that You can clean messy data, analyze patterns, automate repetitive tasks, and even build small data models all in one place. And the best part is, you don’t need to be a programmer to start using it effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where Excel shows up in the real world&lt;/strong&gt;&lt;br&gt;
a)  In business and finance, Excel is used to track income, expenses, and profits. People build forecasts and budgets using spreadsheets, helping companies plan ahead.&lt;br&gt;
b)  In marketing, teams use Excel to track campaign performance. By analyzing that data, they can figure out what’s working and what’s not.&lt;br&gt;
c)  Human resources departments use it to manage employee records, monitor attendance, and even analyze staff perfomance.&lt;br&gt;
d)  Even in operations, Excel plays a role in managing inventory and tracking supply chains. It helps businesses stay organized and avoid costly mistakes.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Excel Features and formulas *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As I’ve been practicing, a few Excel features have really stood out to me because of how practical they are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. SUM and AVERAGE&lt;/strong&gt;&lt;br&gt;
These are basic but essential functions.&lt;br&gt;
     &lt;strong&gt;&lt;em&gt;=SUM(A1:A10)&lt;/em&gt;&lt;/strong&gt;adds up values.&lt;br&gt;
     &lt;strong&gt;&lt;em&gt;=AVERAGE(A1:A10)&lt;/em&gt;&lt;/strong&gt; calculates the mean.&lt;br&gt;
In real-world scenarios, these are used to calculate total , average scores, or overall performance metrics.&lt;br&gt;
&lt;strong&gt;2. IF Statements&lt;/strong&gt;&lt;br&gt;
The IF function allows conditional logic:&lt;br&gt;
    &lt;strong&gt;&lt;em&gt;=IF(A1&amp;gt;50, "Pass", "Fail")&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
This is useful when categorizing data. For example, a company could use it to label customers as “High Value” or “Low Value” based on their spending.&lt;br&gt;
&lt;strong&gt;3. VLOOKUP (and XLOOKUP)&lt;/strong&gt;&lt;br&gt;
These functions help retrieve data from tables:&lt;br&gt;
    &lt;strong&gt;&lt;em&gt;=VLOOKUP(A2, A10:B20, 2, FALSE)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
In practice, this is used to match and merge datasets like finding a customer’s details based on their ID.&lt;br&gt;
&lt;strong&gt;4. Pivot Tables&lt;/strong&gt;&lt;br&gt;
Pivot tables are one of the most powerful tools in Excel. They allow you to summarize large datasets quickly. For example, you can take thousands of rows of sales data and instantly see:&lt;br&gt;
• Total sales per region&lt;br&gt;
• Sales by product category&lt;br&gt;
• Monthly performance trends                                                                                            This is something analysts use regularly to turn raw data into insights.&lt;br&gt;
&lt;strong&gt;5. Charts and Visualization&lt;/strong&gt;&lt;br&gt;
Excel also allows you to create charts like bar graphs, line charts, and pie charts. These help communicate findings clearly. Instead of just showing numbers, you can visualize trends making it easier for others to understand the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Applying this to actual data&lt;/strong&gt;&lt;br&gt;
What I’m starting to understand is that Excel is not just about knowing formulas, it’s about how you think about data. Before analyzing anything, you often need to clean it. Remove duplicates, fix errors, and make sure everything is consistent. Then you organize it in a way that makes sense.&lt;br&gt;
From there, you can start asking questions:&lt;br&gt;
What’s increasing? What’s decreasing? Is there a pattern? Excel helps answer those questions step by step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My personal reflection&lt;/strong&gt;&lt;br&gt;
Learning Excel has definitely changed how I see data. Before, I would look at numbers and not think much about them. Now, I find myself trying to understand what those numbers are actually saying. I pay more attention to patterns, trends, and differences. It’s also made me more curious. Instead of just accepting information, I want to explore it and understand where it comes from. I used to think data analysis was something very technical and complicated. But Excel showed me that it actually starts with simple tools and the ability to think critically.&lt;br&gt;
For me, learning Excel hasn’t just been about spreadsheets, it’s been about learning how to make sense of information in a completely different way.&lt;/p&gt;

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