<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Web Scraping]]></title><description><![CDATA[Web Scraping]]></description><link>https://web-scrapingweek13.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 20:45:35 GMT</lastBuildDate><atom:link href="https://web-scrapingweek13.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Week 13 at Dataraflow: Web Scraping World Population Data with Pandas – Why Python Beats Excel Every Time]]></title><description><![CDATA[December 15, 2025
Hey everyone! Welcome back to my learning journey at Dataraflow. This is Week 13, and I'm diving deeper into the power of Python for data tasks. I started with old YouTube video – the one comparing Pandas/Python to Excel using a web...]]></description><link>https://web-scrapingweek13.hashnode.dev/week-13-at-dataraflow-web-scraping-world-population-data-with-pandas-why-python-beats-excel-every-time</link><guid isPermaLink="true">https://web-scrapingweek13.hashnode.dev/week-13-at-dataraflow-web-scraping-world-population-data-with-pandas-why-python-beats-excel-every-time</guid><category><![CDATA[excel]]></category><category><![CDATA[Data Science]]></category><category><![CDATA[Python]]></category><category><![CDATA[webscraping ]]></category><category><![CDATA[population]]></category><category><![CDATA[UN]]></category><category><![CDATA[pandas]]></category><category><![CDATA[Wikipedia]]></category><category><![CDATA[analysis]]></category><category><![CDATA[code]]></category><category><![CDATA[#reporting]]></category><category><![CDATA[stakeholders]]></category><category><![CDATA[dataraflow]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[Ajiboye Raphael]]></dc:creator><pubDate>Mon, 22 Dec 2025 14:19:06 GMT</pubDate><content:encoded><![CDATA[<p><strong>December 15, 2025</strong></p>
<p>Hey everyone! Welcome back to my learning journey at <strong>Dataraflow</strong>. This is <strong>Week 13</strong>, and I'm diving deeper into the power of Python for data tasks. I started with old YouTube video – the one comparing Pandas/Python to Excel using a web scraping example. Well, I've taken that concept and leveled it up big time.</p>
<p>This week, I scraped real-time world population data from Wikipedia, analyzed it, visualized the insights, and even prepared a full stakeholder report. All with just a few lines of Python code. Let's break it down!</p>
<h2 id="heading-the-project-scraping-and-analyzing-global-population-distribution">The Project: Scraping and Analyzing Global Population Distribution</h2>
<p>I chose the Wikipedia page <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population?referrer=grok.com">"List of countries and dependencies by population"</a> <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population?referrer=grok.com">as my data source. It's updated frequently with UN</a> estimates, and as of mid-2025, the world population stands at <strong>approximately 8.232 billion</strong>.</p>
<p>Using <a target="_blank" href="http://pandas.read">pandas.read</a>_html(), I scraped the main table in one line – pulling in ov<a target="_blank" href="https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population?referrer=grok.com">er 200 rows of data (countries, territories, popul</a>ations, and percentages). No manual copy-paste needed!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1766411613305/cdfb3d12-5903-4d6f-bb3b-78f6ec8f51d4.png" alt class="image--center mx-auto" /></p>
<p><em>(Example of Pandas scraping a table from the web – clean and effortless!)</em></p>
<p>Here's a snapshot of the <strong>top 10 most populous countries</strong> (based on 2025 UN estimates):</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Rank</td><td>Country</td><td>% of World Population</td></tr>
</thead>
<tbody>
<tr>
<td>1</td><td>India</td><td>17.3%</td></tr>
<tr>
<td>2</td><td>China</td><td>17.2%</td></tr>
<tr>
<td>3</td><td>United States</td><td>4.20%</td></tr>
<tr>
<td>4</td><td>Indonesia</td><td>3.50%</td></tr>
<tr>
<td>5</td><td>Pakistan</td><td>2.90%</td></tr>
<tr>
<td>6</td><td>Nigeria</td><td>2.70%</td></tr>
<tr>
<td>7</td><td>Brazil</td><td>2.60%</td></tr>
<tr>
<td>8</td><td>Bangladesh</td><td>2.10%</td></tr>
<tr>
<td>9</td><td>Russia</td><td>1.80%</td></tr>
<tr>
<td>10</td><td>Mexico</td><td>1.60%</td></tr>
</tbody>
</table>
</div><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1766411744103/78958b99-d5c1-43a7-9399-7915fb05a8fe.png" alt class="image--center mx-auto" /></p>
<p>(Visualizations like these bar charts make the concentration crystal clear – top 10 countries hold over 55% of humanity!)</p>
<h2 id="heading-key-insights-from-the-analysis">Key Insights from the Analysis</h2>
<ul>
<li><p><strong>Extreme Skewness</strong>: Just the top 10 countries account for more than half the world's population. India and China alone make up over 34%!</p>
</li>
<li><p><strong>Rapid Shifts</strong>: India has overtaken China as #1. Growth is exploding in Africa and South Asia (e.g., Nigeria jumping ranks).</p>
</li>
<li><p><strong>The Long Tail</strong>: Over 200 smaller nations and territories share the remaining ~44%, many with populations under 1 million.</p>
</li>
</ul>
<p>For a better global view:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1766411851472/184ccda6-ae29-4c07-979c-bf4b9d19cc6f.png" alt class="image--center mx-auto" /></p>
<p>(These maps and cartograms really drive home how population is distributed – not evenly at all!)</p>
<h2 id="heading-the-full-code">The Full Code</h2>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

url = <span class="hljs-string">"https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population"</span>
tables = pd.read_html(url, match=<span class="hljs-string">"Population"</span>)
df = tables[<span class="hljs-number">0</span>]

<span class="hljs-comment"># Cleaning and sorting (adapt as needed for table structure)</span>
<span class="hljs-keyword">if</span> isinstance(df.columns, pd.MultiIndex):
    df.columns = [<span class="hljs-string">' '</span>.join(col).strip() <span class="hljs-keyword">for</span> col <span class="hljs-keyword">in</span> df.columns]

<span class="hljs-comment"># Focus on key columns, sort, and visualize...</span>
<span class="hljs-comment"># (Full robust version from my earlier experiments – it handles cleaning, top 20 bar chart, cumulative line chart, and Excel export)</span>
</code></pre>
<p>This script scrapes, cleans, analyzes, plots, and exports – all automatically. Try it yourself; Wikipedia tables can shift slightly, but Pandas makes it resilient.</p>
<h2 id="heading-stakeholder-report-highlights">Stakeholder Report Highlights</h2>
<p>I wrapped it up with a professional report:</p>
<ul>
<li><p><strong>Economic Implications</strong>: Future markets will be dominated by these top nations.</p>
</li>
<li><p><strong>Environmental Pressure</strong>: High-density areas need sustainable solutions fast.</p>
</li>
<li><p><strong>Recommendations</strong>: Businesses target emerging giants; policymakers focus on education and urbanization in growth hotspots.</p>
</li>
</ul>
<h2 id="heading-why-this-matters-and-why-python-gt-excel-here">Why This Matters (And Why Python &gt; Excel Here)</h2>
<p>Excel's "Data from Web" is okay for one-off imports, but Python shines for:</p>
<ul>
<li><p>Automation &amp; reproducibility</p>
</li>
<li><p>Handling large/skewed datasets</p>
</li>
<li><p>Instant visualizations and stats</p>
</li>
<li><p>Scaling to multiple pages or scheduled runs</p>
</li>
</ul>
<p>This project solidified for me how powerful Pandas is for real-world data flows.</p>
<h2 id="heading-whats-next">What's Next?</h2>
<p>Week 14: Maybe scheduling this scraper with cron/airflow or combining it with API data (e.g., World Bank indicators). But, my boss at DATARAFLOW DECIDES.</p>
<p>Thanks for reading! If you're on a similar data journey, drop a comment – what's your favorite web scraping win?</p>
<p>#DataScience #Python #Pandas #WebScraping #PopulationData #DataraflowJourney</p>
<p><em>Follow me on Hashnode for more weekly updates!</em></p>
]]></content:encoded></item></channel></rss>