<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ethansusuluwa on Medium]]></title>
        <description><![CDATA[Stories by Ethansusuluwa on Medium]]></description>
        <link>https://medium.com/@ethansusuluwa?source=rss-ba360388e060------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-k0qSF6ZSosja1Dr</url>
            <title>Stories by Ethansusuluwa on Medium</title>
            <link>https://medium.com/@ethansusuluwa?source=rss-ba360388e060------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:35:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ethansusuluwa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Structures and Algorithms in Python: What I Learnt]]></title>
            <link>https://medium.com/@ethansusuluwa/data-structures-and-algorithms-in-python-what-i-learnt-eda07ccb3377?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/eda07ccb3377</guid>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dsa-training]]></category>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Sun, 29 Nov 2026 21:18:18 GMT</pubDate>
            <atom:updated>2026-11-29T21:18:18.155Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEiCjxhUBlreNSNZChJCSw.png" /></figure><h3>Big-O, hashing, stacks, recursion and binary search, explained by a data learner</h3><p>So far my data course has been about pandas, SQL and charts. Then it changed direction: <strong>data structures and algorithms (DSA)</strong>. At first I wondered why a data analyst needs this. By the end of the module I had my answer: pandas, SQL and every database I use are built on these ideas, and knowing them explains why some code finishes in a second and some takes all afternoon.</p><p>This post covers what I learnt, the ten problems I solved in the take-home, what I found hard, and what helped.</p><h3>What I learnt</h3><h3>1. A data structure is how you store data; an algorithm is the steps you follow</h3><p>The clearest example for me: imagine a market trader checking whether a customer owes her money.</p><ul><li>If she writes names in a notebook as people come, she has to <strong>read every line</strong> (a list, searched one by one).</li><li>If the names are in <strong>alphabetical order</strong>, she can open the middle and go left or right (a sorted list and binary search).</li><li>If she keeps <strong>one labelled envelope per customer</strong>, she goes straight to the right one (a dictionary or set).</li></ul><p>Same question, same data. Only the storage and the steps change, and that changes the speed completely.</p><h3>2. Big-O describes how work grows, not how many seconds it takes</h3><p>Seconds depend on the computer. Big-O describes what happens to the work when the data gets 10 or 1,000 times bigger. The common classes, from fastest to slowest:</p><ul><li><strong>O(1):</strong> constant, like reading nums[5] or looking up a dictionary key</li><li><strong>O(log n):</strong> halving the problem each step, like binary search</li><li><strong>O(n):</strong> one loop over the data</li><li><strong>O(n log n):</strong> sorting</li><li><strong>O(n²):</strong> a loop inside a loop over the same data</li></ul><p>The most useful rule I learnt: <strong>x in my_list is a hidden loop.</strong> Put it inside another loop and the code becomes O(n²) without you noticing. Changing the list to a set makes each check O(1). In a quick timing test the set was hundreds of times faster on 20,000 items.</p><h3>3. Arrays, two pointers and sliding windows</h3><p>A Python list is an array: jumping to any position is instant, but inserting at the front shifts every other item along, which costs O(n). Two techniques came up again and again:</p><ul><li><strong>Two pointers:</strong> one at each end of a sorted list, moving inwards. Finding two prices that add to a target takes one pass instead of checking every pair.</li><li><strong>Sliding window:</strong> for questions about a run of consecutive items, such as the best 7 days of sales. Instead of re-adding the whole window each time, you add the day coming in and subtract the day going out.</li></ul><h3>4. Hash maps and sets</h3><p>A dictionary turns each key into a “box number” with a hash function, so finding a key takes about the same time no matter how much data there is. Four patterns cover most problems: <strong>counting</strong> (Counter), <strong>seen before?</strong> (set), <strong>complement lookup</strong> (store what you have seen, look up what you need), and <strong>grouping</strong> (defaultdict(list)).</p><p>This was the moment pandas made more sense to me: groupby and SQL’s GROUP BY are both building a hash map from each group to its rows.</p><h3>5. Linked lists, stacks and queues</h3><ul><li>A <strong>linked list</strong> is a chain of nodes, each pointing to the next. You cannot jump to item 500, but adding at the front is instant.</li><li>A <strong>stack</strong> is last in, first out, like a pile of plates. It is perfect for matching brackets and undo buttons.</li><li>A <strong>queue</strong> is first in, first out, like a bus queue. In Python a deque is the right tool, because list.pop(0) shifts every item each time.</li></ul><h3>6. Recursion</h3><p>A recursive function solves a problem by calling itself on a smaller version, until it reaches a <strong>base case</strong> it can answer directly. The example that convinced me about memoisation: a plain recursive Fibonacci function makes <strong>242,785 calls</strong> to work out the 25th number, because it recalculates the same values again and again. Adding @lru_cache means each value is calculated once.</p><h3>7. Searching and binary search</h3><p>Binary search only works on <strong>sorted</strong> data, but it is remarkable: each comparison throws away half of what is left, so a million items need only about <strong>20 comparisons</strong>. The most surprising idea for me was <strong>binary search on the answer</strong>: instead of searching a list, you search the range of possible answers, as long as the yes/no question only flips once.</p><h3>What I solved</h3><p>The take-home had ten auto-graded problems, each with tests, and three had a speed test on a large input that a slow O(n²) solution would fail. I followed the course’s <strong>UMPIRE</strong> method for each one: Understand, Match, Plan, Implement, Review, Evaluate.</p><ul><li><strong>Best k-day sales:</strong> largest total of k consecutive days. <em>Technique: sliding window.</em></li><li><strong>Two prices that hit a total:</strong> a pair in a sorted list adding to a target. <em>Technique: two pointers.</em></li><li><strong>Group anagrams:</strong> put words with the same letters together. <em>Technique: hash map, with the sorted letters as the key.</em></li><li><strong>Longest run of IDs:</strong> longest run of consecutive numbers. <em>Technique: set, only counting from the start of each run.</em></li><li><strong>Reverse a linked list:</strong> reverse it in place. <em>Technique: three pointers (previous, current, next).</em></li><li><strong>Balanced brackets:</strong> check every bracket is closed correctly. <em>Technique: stack.</em></li><li><strong>Wait for a warmer day:</strong> days until a warmer day, for every day. <em>Technique: monotonic stack.</em></li><li><strong>Flatten a nested basket:</strong> turn nested lists into one flat list. <em>Technique: recursion.</em></li><li><strong>First and last position:</strong> where a value starts and ends in a sorted list. <em>Technique: two binary searches.</em></li><li><strong>Smallest truck capacity:</strong> smallest capacity that delivers everything in time. <em>Technique: binary search on the answer.</em></li></ul><p>All ten passed their tests and all three speed tests passed, for <strong>29 out of 29 points</strong>.</p><p>The truck problem is the one I am proudest of. The answer must lie between the heaviest parcel and the total weight of all the parcels. For any capacity I can count how many days the deliveries take, and if a capacity works, every bigger capacity works too. That one-way pattern is what makes binary search possible:</p><pre>lo, hi = max(weights), sum(weights)<br>while lo &lt; hi:<br>    mid = (lo + hi) // 2<br>    if days_needed(mid) &lt;= days:<br>        hi = mid        # mid works, try smaller<br>    else:<br>        lo = mid + 1    # too small<br>return lo</pre><p>There was also an optional SQL practice section showing the same ideas inside a database: GROUP BY as a hash map, NOT EXISTS as a search that stops at the first match, running totals as prefix sums, and window functions as sliding windows (each city’s warmest 7-day period in 2014).</p><h3>Challenges I faced</h3><p><strong>Linked list pointers.</strong> Changing pointers in the wrong order loses the rest of the list. When inserting a node, the new node must take hold of the rest of the chain <em>before</em> the previous node points to it.</p><p><strong>Off-by-one errors in binary search.</strong> Mixing up lo &lt;= hi with lo &lt; hi, or writing lo = mid instead of lo = mid + 1, gives answers that are almost right or loops that never end.</p><p><strong>Believing the monotonic stack is O(n).</strong> There is a loop inside a loop, so it looks like O(n²). It clicked when I counted differently: each day is pushed onto the stack once and popped at most once, so the total work is about 2n.</p><p><strong>Trusting recursion.</strong> Writing flatten(item) inside flatten felt like cheating. I had to accept the “leap of faith”: assume the smaller call already works, and only think about the base case and one step.</p><h3>How I overcame them</h3><ul><li><strong>Tracing by hand.</strong> For linked lists and binary search I wrote out lo, hi and mid, or the pointers, at each step on paper for a small example. Most of my bugs showed up in the first two or three steps.</li><li><strong>Brute force first.</strong> For the warmer-day problem I wrote the slow double loop first, checked it was correct, then replaced it with the stack. Having a correct slow answer made it easier to trust the fast one.</li><li><strong>Edge cases in the tests.</strong> Empty lists, one item, repeated values and negative numbers caught most of my mistakes before the speed tests did.</li><li><strong>Picking one binary search template</strong> and copying it exactly every time, instead of improvising.</li></ul><h3>What I would tell another beginner</h3><ol><li><strong>Learn the cost of everyday operations.</strong> in on a list, list.pop(0) and insert(0, x) are O(n). Knowing that one fact will speed up a lot of real code.</li><li><strong>Ask “what does this remind me of?”</strong> Consecutive items suggest a sliding window, “seen before” suggests a set, matching pairs suggest a stack, and sorted data suggests binary search.</li><li><strong>Write the slow version first.</strong> A correct slow answer is a better starting point than a fast wrong one.</li><li><strong>Connect it to what you already use.</strong> Once I saw that groupby is a hash map and a database index is a kind of binary search, DSA stopped feeling like a separate subject.</li></ol><p>Next up are trees, heaps, graphs and more. If this first part is anything to go by, they will change how I think about the tools I already use.</p><p><em>Thanks for reading. If you are also learning data analysis, I would love to hear which topic clicked for you, and which one did not.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eda07ccb3377" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grouping and Aggregating Trade Data in pandas]]></title>
            <link>https://medium.com/@ethansusuluwa/grouping-and-aggregating-trade-data-in-pandas-20bfbafce3fd?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/20bfbafce3fd</guid>
            <category><![CDATA[dataraflow-intern]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Sat, 31 Oct 2026 22:08:43 GMT</pubDate>
            <atom:updated>2026-10-31T22:08:43.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_bMGDWYIxqAGCO8lmAPbQ.png" /></figure><h3>From UK milk to Nigerian cocoa: split-apply-combine on real UN Comtrade data</h3><p>This week of my data course was about one idea that turns out to be everywhere in data analysis: <strong>split-apply-combine</strong>. Split a table into groups, apply a calculation to each group, and combine the answers into one result.</p><p>I practised it on UN Comtrade trade data. First on the course’s data about the UK’s milk and cream trade, then on my own download: <strong>Nigeria’s cocoa bean exports in 2023</strong>. Getting my own data to work taught me almost as much as the lessons did.</p><h3>What I learnt</h3><h3>1. groupby() is SQL’s GROUP BY</h3><p>If you have written GROUP BY in SQL, you already know the idea:</p><pre>milk.groupby(&quot;Partner&quot;)[&quot;Trade Value (US$)&quot;].sum()</pre><p>reads as “for each partner, add up the trade value”. It is the same as:</p><pre>SELECT Partner, SUM([Trade Value (US$)]) FROM milk GROUP BY Partner</pre><p>A helpful way to read any groupby line: <strong>for each [group], calculate the [function] of [column]</strong>.</p><h3>2. You can look inside the groups</h3><p>A groupby() does not throw rows away. It sorts them into groups and keeps them all ready. You can list the group names with .groups.keys(), count rows with .size(), and pull out one group as its own table with get_group().</p><p>When you group on two columns, each group’s name is a <strong>pair</strong>:</p><pre>groups = milk.groupby([&quot;Partner&quot;, &quot;Trade Flow&quot;])<br>groups.get_group((&quot;France&quot;, &quot;Imports&quot;))</pre><p>The pair must be in the <strong>same order</strong> as the column list. (&quot;Imports&quot;, &quot;France&quot;) fails.</p><h3>3. Three things you can do to a group</h3><ul><li><strong>Summarise it:</strong> one value per group, such as a total, mean or maximum. .agg([&quot;sum&quot;, &quot;mean&quot;, &quot;max&quot;]) gives several at once.</li><li><strong>Filter it:</strong> keep or drop whole groups. For example, keep only the partners that bought something every month.</li><li><strong>Apply your own function:</strong> apply() runs any function you write on each group, such as “give me the top two rows”.</li></ul><h3>4. Pivot tables</h3><p>A pivot table is grouping by two things with one of them spread across the columns. With trade data, putting partners as rows and imports and exports as columns instantly shows which countries trade in <strong>both</strong> directions.</p><h3>5. Plotting with Seaborn</h3><p>The second half of the week covered Seaborn: histograms, density (KDE) plots, box and violin plots, regression plots and heatmaps. One practical lesson: trade values range from a few dollars to hundreds of millions, so most plots only become readable on a <strong>log scale</strong>.</p><h3>What I solved</h3><h3>The UK milk project</h3><p>The course project analysed the UK’s milk and cream trade for January to May 2015. The answers came straight from grouping:</p><ul><li><strong>Balance:</strong> exports of about US$265 million against imports of about US$156 million, a surplus of over US$100 million.</li><li><strong>Main partners:</strong> Ireland was the biggest partner in both directions. It bought about US$128 million of UK milk and sold the UK about US$46 million.</li><li><strong>Reach:</strong> the UK exported to 107 countries but imported from only 21.</li><li><strong>Regular customers:</strong> countries that bought both milk types in all five months accounted for about 76% of exports.</li></ul><p>One detail caught my eye. The project’s written conclusion says there are <strong>16</strong> regular customers, but when I ran the code, the list had <strong>17</strong> countries. A small thing, but a good reminder to trust the output over the text, and to read results carefully rather than skimming them.</p><h3>A sanity check I liked</h3><p>Comtrade includes a “World” row for every month, which is the total of all countries. In the lesson’s 2014 data, adding up the individual countries gave <strong>US$222,107,771</strong> of fresh milk imports, against <strong>US$222,107,770</strong> in the World row. A difference of one dollar, from rounding. When two different routes give the same answer, you can trust your filtering.</p><h3>My own data: Nigeria’s cocoa exports in 2023</h3><p>For my own analysis I chose <strong>cocoa beans (HS code 1801)</strong> with <strong>Nigeria</strong> as the reporter. Nigeria is one of the world’s major cocoa producers, so I expected a strong export story. The results:</p><ul><li><strong>Exports:</strong> about <strong>US$669 million</strong> in 2023, to 20 countries.</li><li><strong>Imports:</strong> almost nothing. A single shipment of about US$128,000, from the Netherlands, in November. That makes sense for a producing country.</li><li><strong>Top buyers:</strong> the <strong>Netherlands</strong> (about US$263 million, 39% of all exports), <strong>Malaysia</strong> (US$172 million) and <strong>Indonesia</strong> (US$80 million). Together these three bought <strong>77%</strong> of Nigeria’s cocoa.</li><li><strong>Regular customers:</strong> only those same three countries bought cocoa from Nigeria <strong>every month</strong> of 2023.</li></ul><p>The monthly totals showed a clear pattern:</p><ul><li><strong>High season:</strong> November to February, with the peak in <strong>December</strong> (about US$124 million).</li><li><strong>Low season:</strong> April to September, with the lowest month in <strong>September</strong> (about US$16 million).</li></ul><p>This likely reflects the main harvest season for West African cocoa, which runs roughly from October to March. One year of data can only show a pattern, not prove it, but it is a striking one.</p><p>And the sanity check worked again: in every month, the country rows added up exactly to the World total.</p><h3>Challenges I faced</h3><p>Most of my problems this week came from <strong>getting my own data into shape</strong>, not from pandas itself.</p><p><strong>1. My first download was the wrong kind of data.</strong> I first downloaded Nigeria’s trade for “All commodities”, for the whole year, and imports only. The task needed one product, monthly figures, and both imports and exports. With imports only, every export question came out empty. With a single yearly figure, there was no month-by-month pattern to find, and every partner counted as a “regular customer”, which is meaningless.</p><p><strong>2. The columns came out shifted.</strong> When I loaded my Comtrade file, the “Trade Flow” column was full of numbers like 634 and 646, and “Period” showed 566. It turned out that the new Comtrade CSV files end every row with an extra comma. pandas reads that as one more column than the header has, uses the first column as row labels, and slides every value one column to the left. 566 is actually Nigeria’s country code.</p><p><strong>3. “Import” is not “Imports”.</strong> The course data says “Imports” and “Exports”, but the new Comtrade files say “Import” and “Export”. My filter for &quot;Imports&quot; matched nothing, so my list of import partners was empty, and the next line crashed with an IndexError when it tried to take the first item.</p><p><strong>4. An older copy of the notebook.</strong> At one point I fixed the code, then ran an older saved copy by mistake and got the same errors again.</p><h3>How I overcame them</h3><ul><li><strong>Re-downloading with the right settings:</strong> Goods, Monthly, HS code 1801, Nigeria, all partners, all twelve months of 2023, and both Import and Export ticked. Monthly data turned out to be available for Nigeria for this product.</li><li><strong>One argument fixed the shifted columns:</strong> pd.read_csv(file, index_col=False) tells pandas not to use the first column as row labels.</li><li><strong>Cleaning the flow names</strong> so that “Import”, “Imports” and similar spellings all become the same value before filtering.</li><li><strong>Printing before analysing:</strong> printing the trade flow values, the number of periods and the commodity codes right after loading made the problems obvious.</li><li><strong>Restarting the kernel</strong> and running everything from the top, so no old values were left over.</li></ul><p>What I would do differently: check the data’s shape <strong>before</strong> writing any analysis. Three lines of printing would have saved me most of an evening.</p><h3>Advice for anyone learning this</h3><ol><li><strong>Ask what one row represents.</strong> In Comtrade data, one row is one partner, one product, one flow and one month. If your question is about partners, group by partner before you sort.</li><li><strong>Remove the World rows</strong> before adding anything up, or every total is counted twice.</li><li><strong>Check one answer two ways</strong>, for example the sum of the countries against the World row.</li><li><strong>Print the unique values</strong> of any column you filter on. “Import” and “Imports” look the same to a person but not to pandas.</li><li><strong>When an error says something is empty or out of bounds</strong>, look at the step before it. The bug is usually in the filter, not the line that crashed.</li></ol><h3>Final thought</h3><p>Split-apply-combine sounds abstract, but it answers the questions people actually ask: who are our biggest customers, which months are busiest, and who buys from us every month. Using it on Nigeria’s cocoa trade made those answers real. The Netherlands buys about two in every five dollars of Nigeria’s cocoa exports, and the trade follows the harvest calendar.</p><p><em>Data: UN Comtrade (UK milk and cream, 2014 and January to May 2015, via the course database; Nigeria cocoa beans HS 1801, monthly 2023, downloaded from comtradeplus.un.org). Useful docs: </em><a href="https://pandas.pydata.org/docs/user_guide/groupby.html"><em>pandas group by guide</em></a><em>, </em><a href="https://comtradeplus.un.org/"><em>UN Comtrade</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20bfbafce3fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cleaning, Combining and Visualising Data in pandas: What I Learnt]]></title>
            <link>https://medium.com/@ethansusuluwa/cleaning-combining-and-visualising-data-in-pandas-what-i-learnt-06a331cf0ab6?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/06a331cf0ab6</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[dataraflow-intern]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 20:35:17 GMT</pubDate>
            <atom:updated>2026-10-25T20:56:21.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YIP9UXv9BtpWCu6Rmruhg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jakubzerdzicki?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jakub Żerdzicki</a> on <a href="https://unsplash.com/photos/fingers-interacting-with-a-stock-market-graph-on-a-tablet-lnuOh9vs8v0?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Planning a London holiday from weather records, and finding out why total GDP is a poor measure of wealth</h3><p>This week of my data course was about three skills: cleaning messy data, combining tables, and turning numbers into charts. The work had two projects.</p><ol><li>Use 2014 London weather data to find the best two weeks for a summer holiday.</li><li>Combine World Bank tables to see whether richer countries have longer life expectancy, then design my own project with two new indicators.</li></ol><p>There was also a set of SQL practice tasks doing the same cleaning and combining jobs directly in the database. All five passed.</p><p>Here is what I did, what went wrong, and what I learnt.</p><h3>Part 1: Cleaning the weather data</h3><p>The London weather table comes from a raw Weather Underground export, and the messiness was left in on purpose. Three problems showed up straight away.</p><p><strong>Hidden spaces in column names.</strong> Names like &quot; Mean Humidity&quot; and &quot; Events&quot; start with a space. Typing london[&quot;Mean Humidity&quot;] gives a KeyError, even though the column is right there on screen. One line fixes every name at once:</p><pre>london.columns = london.columns.str.strip()</pre><p><strong>HTML stuck to the data.</strong> The last column was called WindDirDegrees&lt;br /&gt;, and every value looked like &#39;186&lt;br /&gt;&#39;. Because of that text, pandas stored wind direction as words, not numbers. I renamed the column, removed the &lt;br /&gt; from every value, then converted it to integers.</p><p><strong>Dates stored as text.</strong> The date column held strings like &#39;2014-1-1&#39;. Converting it with pd.to_datetime() and making it the index changed what I could do. Selecting a date range became one readable line:</p><pre>summer = london.loc[&quot;2014-06-01&quot;:&quot;2014-08-31&quot;]</pre><p>With clean data, the lesson tasks were quick. London had <strong>12 days</strong> in 2014 with a northerly wind (350 degrees or more, or 10 or less). <strong>234 days</strong> had no gust speed recorded, which is a reminder that “missing” is often the normal state of a column, not a mistake.</p><h3>Part 2: Finding the best two weeks</h3><p>A good holiday fortnight should be warm and dry. For every possible 14-day period in June, July and August, I calculated the average maximum temperature and the total rain. Then I kept only the warm periods and picked the driest.</p><p>The rolling() method did most of the work. It took me a moment to understand one detail: rolling(14) looks <strong>backwards</strong>, so each value belongs to the 14 days <em>ending</em> on that date. Adding .shift(-13) moved each value to the period <em>starting</em> on that date, which is what a holiday planner wants.</p><p><strong>The answer: 11 to 24 July 2014.</strong> The average maximum temperature was 26.9C, 12 of the 14 days reached 25C or more, and only 1.0mm of rain fell in the whole fortnight.</p><p>The monthly summary told the same story:</p><ul><li><strong>July:</strong> warmest (25.5C average maximum) and fewest rain days (14).</li><li><strong>June:</strong> 21.7C, 26.9mm of rain.</li><li><strong>August:</strong> coolest (21.5C) and much the wettest, with 81.3mm of rain and rain recorded on 23 of 31 days.</li></ul><h3>A data quirk worth knowing about</h3><p>Seven days in my chosen fortnight have “Rain” in the Events column. Yet 12 of the 14 days recorded <strong>0.00mm</strong> of precipitation.</p><p>The two columns don’t contradict each other. A light shower can be logged as a rain event while being too small to measure. But if I had ranked periods by counting rain events, I would have rejected the best fortnight of the summer. <strong>The precipitation total is a much better measure of how wet a period really was.</strong></p><h3>Checking one answer two ways</h3><p>SQL Task 5 asked for the driest 7-day period of the summer, using a window function:</p><pre>SUM(rain_mm) OVER (ORDER BY day ROWS BETWEEN CURRENT ROW AND 6 FOLLOWING)</pre><p>My pandas version, using rolling(7), gave exactly the same answer: the week starting <strong>19 June</strong>, with 0.0mm of rain. When two different methods agree, I trust the result much more.</p><h3>Part 3: Combining World Bank data</h3><p>The second project joined World Bank tables for GDP, life expectancy and population in 2013.</p><h3>Groups hiding among the countries</h3><p>The first 34 rows of each World Bank table are not countries at all. They are groups like “Arab World”, “High income” and “World”. Leaving them in would put “World” next to Luxembourg on a scatterplot. The lesson removes them by slicing from row 34 onwards.</p><p>That works, but it depends on the rows staying in that order. So before slicing, I printed rows 33 and 34 to check: “World”, then “Afghanistan”. It’s a one-line check that would catch the problem if the order ever changed.</p><h3>The four kinds of join</h3><p>The lesson explained left, right, outer and inner joins on tiny tables. I built a six-country population table using real 2013 figures from the database and joined it four ways.</p><ul><li><strong>Left:</strong> keeps the rows from the first table.</li><li><strong>Right:</strong> keeps the rows from the second table.</li><li><strong>Outer:</strong> keeps everything from both, with NaN where a value is missing.</li><li><strong>Inner:</strong> keeps only the rows found in both tables.</li></ul><p>Building that table surfaced a real problem: the World Bank calls Russia <strong>“Russian Federation”</strong>. Without renaming it, Russia would have silently failed to match. That was the same lesson I learnt last week, when 28 countries vanished from a join on names. This time I knew to look for it.</p><h3>A small bug in the example</h3><p>The example analysis used merge(...) without ever importing it, so it stopped with NameError: name &#39;merge&#39; is not defined. The fix was either from pandas import merge or writing pd.merge(...). It was a small thing, but it taught me to read error messages calmly: the last line usually names the exact problem.</p><h3>Part 4: Total GDP is the wrong question</h3><p>The example analysis found a correlation of <strong>0.50</strong> between a country’s total GDP and its life expectancy, and concluded there was “no strong correlation” between wealth and how long people live.</p><p>The assignment asked me to redo it using <strong>GDP per capita</strong>, which is GDP divided by population. Here is how the correlation with life expectancy changed:</p><ul><li><strong>Total GDP:</strong> 0.50 (moderate)</li><li><strong>GDP per capita:</strong> 0.85 (strong)</li><li><strong>GDP per capita, adjusted for prices (PPP):</strong> 0.86 (strong)</li></ul><p><strong>Total GDP mixes up two things: how rich each person is, and how many people there are.</strong> China and India have huge economies mainly because they have huge populations. Dividing by population removes that, and the relationship between wealth and life expectancy becomes clear.</p><p>The top-10 lists showed it too. Only 3 of the 10 largest economies (France, Italy and Japan) were among the 10 countries with the longest life expectancy.</p><p>Two countries stood out: <strong>Nigeria</strong> (life expectancy 52) and <strong>South Africa</strong> (57). Both have large economies, but countries with a similar total GDP averaged about 76 to 77 years, so both were roughly 20 years behind their peers. Large total GDP can sit alongside low income per person, inequality and a heavy disease burden.</p><p>The lesson for me: <strong>before calculating a correlation, check that the measure fits the question.</strong> A correct calculation on the wrong measure still gives a misleading answer.</p><h3>Part 5: My own project</h3><p>For my own project I wanted two new indicators that compare fairly between countries, so both had to be measured <strong>per person</strong> rather than as totals:</p><ul><li><strong>Health spending per person</strong> (current US$)</li><li><strong>Under-five mortality:</strong> deaths before age five per 1,000 live births</li></ul><p>My question: do countries that spend more on health per person lose fewer young children?</p><h3>Getting data that wasn’t in the database</h3><p>The course database only had GDP, life expectancy and population, so I downloaded these two indicators from the World Bank’s public data service. That raised two practical problems.</p><ol><li><strong>Removing the groups again.</strong> I couldn’t rely on “the first 34 rows” this time. Instead, I downloaded the World Bank’s list of countries and kept only entries that were not marked as aggregates.</li><li><strong>Matching countries reliably.</strong> After last week’s lesson, I joined the tables on the <strong>ISO three-letter country code</strong> instead of the name. Both indicators came from the same source, but codes still avoid any spelling surprises.</li></ol><h3>The result</h3><p>The Spearman correlation was <strong>-0.89</strong>: strong, negative and statistically significant. The more a country spends on health per person, the fewer children die before their fifth birthday.</p><p>Splitting the 190 countries into four equal groups by spending made the size of the gap clear. Average under-five deaths per 1,000 births:</p><ul><li><strong>Lowest 25%</strong> (US$13 to US$97 per person): 75.3</li><li><strong>Lower middle:</strong> 29.5</li><li><strong>Upper middle:</strong> 17.1</li><li><strong>Highest 25%</strong> (US$992 or more): 5.9</li></ul><p>That is a difference of more than 12 times between the lowest and highest spenders.</p><h3>The exceptions were the most interesting part</h3><p>I fitted a simple line through the data and compared each country with it.</p><ul><li><strong>Sri Lanka</strong> spent US$133 per person, but its child mortality was 9.8 per 1,000, about <strong>a third</strong> of what its spending predicts.</li><li><strong>Equatorial Guinea</strong> spent US$286 per person, but its rate was 98.6 per 1,000, almost <strong>five times</strong> what its spending predicts.</li></ul><p>Belarus, Montenegro, Estonia and Czechia also did much better than expected. Namibia, Botswana, South Africa and Sierra Leone did much worse. How money is spent, and on whom, clearly matters as well as how much.</p><p>Correlation is not causation, though. Richer countries spend more on health <strong>and</strong> have better nutrition, sanitation and education, so wealth may be driving both indicators.</p><h3>What I found hardest</h3><ul><li><strong>Knowing which direction a window looks.</strong> rolling() looks backwards, while my SQL window looked forwards. Getting the start dates right took careful checking.</li><li><strong>Choosing the right measure.</strong> The total GDP result looked like a finished answer. It was only the per capita redo that showed how misleading it was.</li><li><strong>Trusting row positions.</strong> Slicing at row 34 felt fragile, so I added a check rather than assuming.</li><li><strong>Log scales.</strong> With incomes ranging from about £150 per person in Malawi to tens of thousands of pounds in the richest countries, a normal axis squashes almost every country into one corner. A log scale spreads them out, but it took some practice to read.</li></ul><h3>What helped</h3><ol><li><strong>Printing column names and data types first</strong>, before any analysis.</li><li><strong>Checking assumptions in code</strong>, such as printing rows 33 and 34 before slicing.</li><li><strong>Getting the same answer two ways</strong>, such as pandas and SQL for the driest week.</li><li><strong>Joining on codes, not names</strong>, whenever codes are available.</li><li><strong>Asking whether a measure is fair</strong> before trusting a correlation.</li></ol><h3>Final thought</h3><p>This week showed me that cleaning and combining data is not just preparation for the “real” analysis. The decisions made along the way changed the conclusions: rain events or rain totals, total GDP or GDP per person, names or codes. Each one changed the story the data told.</p><p><em>Data: London 2014 daily weather (Weather Underground, via the course database) and World Bank World Development Indicators for 2013. Useful docs: </em><a href="https://pandas.pydata.org/docs/"><em>pandas</em></a><em>, </em><a href="https://data.worldbank.org/"><em>World Bank Data</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06a331cf0ab6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning NumPy, pandas and SQL: The Beginner Mistakes That Don’t Show an Error]]></title>
            <link>https://medium.com/@ethansusuluwa/learning-numpy-pandas-and-sql-the-beginner-mistakes-that-dont-show-an-error-30395f3e0923?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/30395f3e0923</guid>
            <category><![CDATA[python-libraries]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[datara-flow]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 21:07:56 GMT</pubDate>
            <atom:updated>2026-10-18T21:07:56.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RBFHcziBLQJWIbEo-ZF1Jw.jpeg" /></figure><h3>Notes from a week of data tasks, and the traps a new learner is likely to hit</h3><p>This week I worked through a set of NumPy, pandas and SQL tasks. Most of them looked simple on paper. Test an array for missing values. Show the first ten rows of a table. Count the rainy days in London.</p><p>The hardest part was not the syntax. It was the mistakes that <strong>don’t</strong> produce an error: the ones where the code runs and the answer is still wrong.</p><p>For example, when I joined WHO tuberculosis data to World Bank population data on country names, the query ran without a problem. But 28 WHO countries had no match, including the United Kingdom and the United States, because the two sources spell country names differently.</p><p>This article covers the traps I met, and others a beginner is likely to meet, and what helped me get past them.</p><h3>What I worked on</h3><p>The week had four parts:</p><ul><li><strong>NumPy:</strong> testing arrays for missing values, comparing arrays, measuring memory.</li><li><strong>pandas:</strong> filtering a WHO dataset of population and tuberculosis deaths, and working with Series.</li><li><strong>An open analysis:</strong> 2014 weather data for six airports (Beijing, Brasilia, Cape Town, Delhi, London and Moscow), pulled from a cohort database.</li><li><strong>Ten SQL tasks:</strong> from exploring a schema up to joins, CTEs and window functions, each checked automatically.</li></ul><p>All ten SQL checks passed in the end. Almost every one of them taught me something on the way.</p><h3>Part 1: NumPy</h3><h3>NaN is not equal to itself</h3><p>The first task was to find missing values. The obvious move is arr == np.nan.</p><p>It returns False for everything, including the NaN.</p><pre>arr = np.array([1, 0, np.nan, np.inf])<br>np.isnan(arr)    # [False False  True False]<br>arr == np.nan    # [False False False False]  &lt;- the trap</pre><p>By definition, NaN (Not a Number) is not equal to anything, not even another NaN. You need np.isnan().</p><p>Remember this one, because it comes back in pandas as isna() and in SQL as IS NULL. Same idea, three names.</p><h3>Decimals are almost never exactly equal</h3><p>Computers store decimals in binary, so 0.1 + 0.2 == 0.3 is False.</p><p>np.allclose() fixes this by comparing within a tolerance. The catch is that there are <strong>two</strong> tolerances: a relative one (rtol) and an absolute one (atol).</p><p>In my exercise, 1e-7 and 1e-8 counted as “close”, while two large numbers counted as different. If you don’t know both tolerances exist, the output looks random.</p><h3>Memory depends on the data type</h3><p>An array of four integers used 32 bytes on my machine: 4 elements times 8 bytes each. But integers are not always 8 bytes. Windows has historically defaulted to 4-byte integers.</p><p>If a number surprises you, check arr.dtype first.</p><h3>Part 2: pandas</h3><h3>The 55th row is row 54</h3><p>“Display the 55th row” sounds like df.iloc[55]. It is df.iloc[54], because Python counts from zero.</p><p>pandas also has two ways to pick rows. iloc uses position. loc uses the index label. They usually agree, right up until you filter or sort, and then they suddenly don’t.</p><h3>One bracket or two?</h3><p>df[&quot;Country&quot;] gives you one column as a Series.</p><p>df[[&quot;Country&quot;, &quot;TB deaths&quot;]] gives you a DataFrame.</p><p>The double brackets look like a typo. Read them as “select this <strong>list</strong> of columns” and they make sense.</p><h3>and, or and the error nobody understands</h3><p>Filtering with two conditions produces many beginners’ first truly confusing error.</p><pre># Fails: &quot;The truth value of a Series is ambiguous&quot;<br>df[df[&quot;Population (1000s)&quot;] &lt;= 50000 or df[&quot;TB deaths&quot;] &gt;= 20000]</pre><pre># Works<br>df[(df[&quot;Population (1000s)&quot;] &lt;= 50000) | (df[&quot;TB deaths&quot;] &gt;= 20000)]</pre><p>pandas needs &amp; and | instead of and and or. Each condition also needs its own brackets, because | binds more tightly than &lt;=.</p><h3>Column names lie</h3><p>The weather data had column names like &quot; Events&quot; and &quot; Mean Humidity&quot;, with a hidden leading space. Another ended in a stray HTML tag: WindDirDegrees&lt;br /&gt;.</p><p>So data[&quot;Events&quot;] throws a KeyError, even though “Events” is right there on your screen.</p><p>My fix: print df.columns before doing anything, then clean the names once.</p><pre>data.columns = [c.replace(&quot;&lt;br /&gt;&quot;, &quot;&quot;).strip() for c in data.columns]</pre><h3>Numbers stored as text</h3><p>One non-numeric value turns a whole column into text. Then sorting goes alphabetical, so &quot;1000&quot; comes before &quot;200&quot;.</p><p>pd.to_numeric(series, errors=&quot;coerce&quot;) converts what it can and turns the rest into NaN. Useful, but count the NaNs afterwards so you know what was quietly thrown away.</p><h3>Tutorials that no longer work</h3><p>Many online answers add data to a Series with .append(). That method was <a href="https://pandas.pydata.org/docs/whatsnew/v2.0.0.html">removed in pandas 2.0</a>. Use pd.concat() instead.</p><p>When an example fails, check the official docs before blaming yourself.</p><h3>Part 3: SQL</h3><h3>You write it in one order, it runs in another</h3><p>You write: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY.</p><p>The database runs it roughly as: FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY.</p><p>That one fact explains three confusing errors:</p><ol><li>You can’t use a SELECT alias in WHERE, because WHERE runs first.</li><li>You <strong>can</strong> use it in ORDER BY, because ORDER BY runs last.</li><li>You can’t filter on COUNT(*) in WHERE. That is exactly what HAVING is for.</li></ol><h3>= NULL never matches</h3><p>WHERE [ Events] = NULL returns nothing, even when many rows are empty. NULL means “unknown”, and comparing with unknown is never true. You need IS NULL.</p><p>It gets worse. A cell can also <em>look</em> empty because it holds an empty string, which is not NULL at all. In London’s data, 114 days had no weather event recorded, and I only got that number by checking for both.</p><h3>The integer division trap</h3><p>In SQL Server, 1 / 4 returns 0. Whole number divided by whole number gives a whole number.</p><p>AVG() does the same. In the churn data, 228 of 500 customers churned, so the true average is 0.456. AVG(Churn) returns <strong>0</strong>. London’s average temperature of 12.3C comes back as 12.</p><p>Nothing errors. The answer is just wrong. The fix is to bring in a decimal first: 100.0 * churned / customers, or CAST(x AS FLOAT).</p><h3>Joins that silently lose rows</h3><p>I joined WHO tuberculosis data to World Bank population data on the country name.</p><p>WHO uses official names: “United Kingdom of Great Britain and Northern Ireland”, “United States of America”, “Viet Nam”. The World Bank uses its own shorter forms. An inner join drops anything that doesn’t match exactly, so 28 countries simply disappeared.</p><blockquote>Count your rows before and after every join. It is the cheapest check in data analysis.</blockquote><p>The professional fix is to join on a standard code, such as the ISO three-letter country code, rather than on free text.</p><p>One more anti-join trap: NOT IN returns nothing at all if the subquery contains a single NULL. NOT EXISTS doesn’t have that problem.</p><h3>UNION removes rows you need</h3><p>Stacking the six weather tables needs UNION ALL. Plain UNION removes duplicate rows. Two days with the same temperature in the same city are real, separate days, and removing them distorts the averages.</p><h3>Window functions are the real step up</h3><p>“Find the hottest day of each month” sounds like GROUP BY. But GROUP BY gives you the hottest <strong>temperature</strong>, not the <strong>day</strong> it happened.</p><p>The answer is a window function:</p><pre>ROW_NUMBER() OVER (<br>    PARTITION BY month<br>    ORDER BY max_temp DESC, day ASC<br>)</pre><p>Keep the rows numbered 1 and you have the hottest day per month, with ties going to the earlier date. Choose carefully: RANK gives tied rows the same number and would return two days for a tied month.</p><p>This was the hardest new idea of the week. Once it clicks, running totals use the same shape: SUM(...) OVER (ORDER BY Period).</p><h3>Part 4: The code ran. The data was wrong.</h3><p>The most useful lesson had nothing to do with syntax.</p><p><strong>The loan data.</strong> One task asked how loan approval varied by property area and credit history. My query passed. The result:</p><ul><li>Every rural application had a credit history of 0, and <strong>every one</strong> was rejected.</li><li>Every semi-urban and urban application had a credit history of 1, and <strong>every one</strong> was approved.</li><li>The groups were almost exactly a third each: 166, 167 and 167.</li></ul><p>Real lending data never looks this clean. A model trained on it would learn “rural means reject”, which is unrealistic and unfair.</p><p><strong>The weather data.</strong> The table labelled Delhi recorded a low of -17C and 14 snow days. Delhi’s winters are mild and snow is essentially unknown there, so the table is probably from a different station or mislabelled.</p><p>Moscow showed <strong>0.0mm</strong> of precipitation for the whole year, despite 114 rain days and 97 snow days. The measurements were missing and had been stored as zeros.</p><p>None of these problems caused an error. All of them would have produced confident, wrong conclusions.</p><blockquote>A correct query on a strange dataset is still a strange result.</blockquote><h3>What actually helped</h3><ol><li><strong>Look before you calculate.</strong> df.shape, df.columns, df.dtypes, df.head(). In SQL, INFORMATION_SCHEMA.COLUMNS. Most of my errors were about names and types, not logic.</li><li><strong>Build in small steps.</strong> FROM and WHERE first. Check. Then GROUP BY. Check. Then the window function.</li><li><strong>Count rows at every stage.</strong> Silent data loss is the most common mistake with no error message.</li><li><strong>Check one answer two ways.</strong> pandas found 114 days with no weather event in London. SQL found the same 114. When two methods agree, trust goes up.</li><li><strong>Read the last line of the error.</strong> pandas errors are long, but the last line usually names the exact problem.</li><li><strong>Ask “does this make sense?”</strong> Every single time.</li></ol><h3>You don’t need charts to analyse data</h3><p>Some environments can’t display charts, and sometimes you want exact numbers anyway. Every chart in my weather analysis had a table equivalent:</p><ul><li><strong>Line chart of monthly temperatures</strong> becomes a pivot table, months as rows and cities as columns.</li><li><strong>Box plot</strong> becomes groupby(&quot;City&quot;)[&quot;Mean TemperatureC&quot;].describe(), which gives min, quartiles, median and max as numbers.</li><li><strong>Bar chart of rain days</strong> becomes a sorted summary table.</li><li><strong>“Which month is hottest?”</strong> becomes idxmax() instead of squinting at a graph.</li></ul><p>The pivot table told the hemisphere story without a single picture. Moscow climbs from -9.6C in January to 19.5C in July. Cape Town falls from 23.0C in February to 12.0C in July. Brasilia barely moves, staying between 20C and 25C all year.</p><h3>Final thought</h3><p>None of these problems are advanced. That is exactly why they catch beginners. Zero-based counting, missing values, numbers stored as text, integer division and joins that lose rows all tend to give you wrong answers rather than errors.</p><p>Learning these tools is less about memorising syntax and more about building habits that catch quiet mistakes. Check the shape. Check the types. Count the rows. Ask whether the result makes sense.</p><p>Expect to hit most of these. Each one only needs to bite you once.</p><p><em>Useful docs: </em><a href="https://numpy.org/doc/stable/"><em>NumPy</em></a><em>, </em><a href="https://pandas.pydata.org/docs/"><em>pandas</em></a><em>, </em><a href="https://learn.microsoft.com/en-us/sql/t-sql/language-reference"><em>Transact-SQL reference</em></a><em>.</em></p><p><em>If this helped, follow me for more notes from my data science journey.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30395f3e0923" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Thought Open Data Was Easy: Sourcing Drilling Data from the Volve Field]]></title>
            <link>https://medium.com/@ethansusuluwa/i-thought-open-data-was-easy-sourcing-drilling-data-from-the-volve-field-931f66a66172?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/931f66a66172</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[maching-learning]]></category>
            <category><![CDATA[geophysics]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[oil-and-gas]]></category>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 18:05:21 GMT</pubDate>
            <atom:updated>2026-10-09T18:05:21.887Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-m53eUCyIdXyg1hTxj4iQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@luandmario?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Maria Lupan</a> on <a href="https://unsplash.com/photos/west-bollsta-drilling-rig-in-harbor-hy97yy3e03A?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I assumed open data meant a download button. It took me most of an afternoon, a lot of trial and error, and some help from a friend who knows his way around data tools before I had four wells I could actually use.</p><p>My research project asks a simple question: can drilling parameters such as rate of penetration, weight on bit, torque, rotary speed and standpipe pressure predict the rock type while a well is being drilled? To test that properly, a model has to be trained on some wells and then tested on a well it has never seen. So I needed several wells, each with drilling data and a gamma ray log over the same depths.</p><p>The obvious source was Volve, a North Sea field whose full dataset Equinor made public in 2018. Coming from geophysics rather than data science, I assumed getting the data would take ten minutes. Here is what it actually took, and what I learned along the way.</p><h3>Where I looked first</h3><p>The easy copies of this data have mostly disappeared, and the one that is left covers a single well.</p><p><strong>Kaggle had one well.</strong> I started from a Kaggle upload of well 15/9-F-9 A: one CSV file of drilling data recorded by depth. It looked big, with 16,670 rows and 115 columns. But only about 1,300 rows actually had a gamma ray reading, several columns were almost empty, and there was a 51 m gap in the gamma ray right where the drill bit was changed. And one well cannot tell you whether a model works on a new well.</p><p><strong>The original source of that file is offline.</strong> The Kaggle file credited a University of Stavanger server, where a researcher had converted the raw Volve drilling files into CSVs for every well. That server now just says “Forbidden”.</p><p><strong>Everything else pointed back to it.</strong> The GitHub projects I found that used Volve drilling data all linked to that same server. None of them had the files themselves.</p><p>If that server were still up, I would have been done in ten minutes. Instead, the only option left was Equinor’s own copy of the data.</p><h3>The real data was hidden in zip files</h3><p>Equinor’s full Volve dataset is available on Databricks, an online platform for working with large data. Every well is there, just not where I expected: the folders I could open held only small index files, and the actual drilling records were packed inside zip files, some around 2 GB.</p><p>The drilling records use a format called WITSML, the oil industry’s standard way of sharing data from the rig. Each well’s records are split into many small files, and each record is organised either by time or by depth. For my project I needed the ones organised by depth.</p><p>I found this out the hard way. Our first attempt searched every well folder and found nothing, not even for F-9 A, which I knew had data. The second attempt found nothing again. Only when I downloaded a couple of folders and looked inside did it make sense: a few tiny index files called MetaFileInfo.txt, and no actual measurements. The real data was in a separate folder, inside one archive called Volve_WITSML Realtime drilling data.zip.</p><h3>What finally worked</h3><p>The version that worked read the files directly from inside the zip, without unzipping it first. In plain terms, it did four things:</p><ol><li><strong>Opened only the drilling zip</strong>, not the seismic and other large archives in the same folder.</li><li><strong>Used the index files as a map.</strong> Each well has a small MetaFileInfo.txt file that lists which folders hold time records and which hold depth records, so only the depth ones were opened.</li><li><strong>Read each file straight from the zip</strong>, one at a time, using tools that come built into Python.</li><li><strong>Combined each well into one CSV file</strong>, with one column per measurement and one row per depth.</li></ol><p>It found 1,075 depth files. Fifteen wells had gamma ray and all five drilling measurements, and four of them (F-9 A, F-10, F-12 and F-15) covered the same depths, which is what a fair test needs.</p><h3>Why it was worth the trouble</h3><p>Having more wells changed what I could honestly say about my project.</p><p>I ran a quick first test. A random forest, a common beginner-friendly machine learning model, tried to tell shale-rich rock from cleaner rock using only the five drilling measurements, on three wells drilled through the same depth range (about 1,200 to 2,600 m). The score is balanced accuracy, where 0.50 is no better than guessing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QyJK2PIr50l1GVTbZb3UrQ.png" /></figure><p>When rows are split randomly, neighbouring readings, which are almost identical, end up in both the training and the test data, so the model gets an easy ride. Tested on wells it had never seen, it still did better than guessing on two of the three wells, but by much less. In the shallower part of the wells, it did no better than guessing. With only one well, I would never have seen any of this.</p><h3>What I learned</h3><p>“Open” means you are allowed to use the data, not that it is ready to use. Five things I would tell another beginner:</p><ol><li><strong>Go to the original source early.</strong> Copies on Kaggle or university servers can disappear. The publisher’s own release is the one that stays.</li><li><strong>Check how much data you really have.</strong> My 16,670 rows turned out to be about 1,300 usable ones.</li><li><strong>Look for index or readme files.</strong> They are a map of the dataset and can save you hours.</li><li><strong>You do not always need to unzip a huge file.</strong> Python can read files straight from inside it.</li><li><strong>Save your code.</strong> It lets you, or anyone else, rebuild the same data later.</li></ol><p>The Volve data is released under the Equinor Open Data Licence, so credit Equinor and check the licence terms before sharing any converted files publicly.</p><p>I went in expecting a download button. I came out with four wells, a working notebook and a much better idea of how much work hides behind the word “open”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=931f66a66172" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[datetime.datetime Isn’t a Typo: What a Birthday Timer Taught Me About Python]]></title>
            <link>https://medium.com/@ethansusuluwa/datetime-datetime-isnt-a-typo-what-a-birthday-timer-taught-me-about-python-f3a0d51a8ad4?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a0d51a8ad4</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 12:14:56 GMT</pubDate>
            <atom:updated>2026-09-26T12:14:56.034Z</atom:updated>
            <content:encoded><![CDATA[<h3>I set out to learn how Python handles dates. I came away understanding modules, classes, and imports for the first time.</h3><p>Dates seemed like the easy part of learning Python.</p><p>Then I saw this:</p><pre>datetime.datetime</pre><p>And this:</p><pre>from datetime import datetime, date</pre><p>Why was the same word written twice? Was one of them a typo? Which datetime was I actually using?</p><p>I had come to learn about dates. Instead, I found myself working through modules, classes, methods, and imports. That detour turned out to be the most useful thing I’ve learned in Python so far.</p><p>Here’s what finally made it click, and the small project that tied it all together.</p><h3>The Double datetime, Explained</h3><p>A <strong>module</strong> is a Python file containing reusable code.</p><p>Python’s standard library includes a module called datetime. Inside it are several <strong>classes</strong>, including one that is <em>also</em> called datetime:</p><pre>datetime → module<br>     ↓<br> ┌─────────────┐<br> │ datetime    │ → class<br> │ date        │ → class<br> │ timedelta   │ → class<br> └─────────────┘</pre><p>So when you see:</p><pre>datetime.datetime</pre><p>the first datetime is the <strong>module</strong> and the second is the <strong>class inside it</strong>.</p><p>Python isn’t repeating itself. It’s giving you an address: <em>go to this module, then find this class.</em></p><h3>import vs from … import</h3><p>Once I understood modules, the two import styles made sense too.</p><p><strong>Option 1: import the whole module.</strong></p><pre>import datetime</pre><pre>datetime.date.today()</pre><p>Here, I reach into the module every time I need something from it.</p><p><strong>Option 2: import just what you need.</strong></p><pre>from datetime import date</pre><pre>date.today()</pre><p>Here, I bring the date class straight into my program, so I can use it directly.</p><p>My mental model:</p><pre>import module            →  module.item<br>from module import item  →  item</pre><p>Neither is “better.” The first makes it obvious where things come from. The second keeps code shorter when you only need a few things.</p><h3>Modules, Packages, and Libraries</h3><p>I used to treat these three words as synonyms. They’re related, but not identical:</p><ul><li>A <strong>module</strong> is a single Python file of reusable code.</li><li>A <strong>package</strong> is a collection of related modules, organized together.</li><li>A <strong>library</strong> is a broader, informal term for a body of reusable code, often made up of packages.</li></ul><p>A simplified picture:</p><pre>Library<br>   ↓<br>Package<br>   ↓<br>Modules<br>   ↓<br>Classes / Functions / Variables</pre><p>Real projects don’t always fit this neatly, but it’s a useful starting point.</p><h3>The Project: A Birthday Countdown</h3><p>To put all this into practice, I built a small program. You type in your birthday, and it tells you how many days are left until the next one.</p><p>Simple on paper. But it immediately raised a problem.</p><h3>Problem 1: input() gives you a string</h3><p>When a user types 25-12-2000, Python doesn&#39;t see a date. It sees a string of characters.</p><p>To convert it, I used strptime() (&quot;string parse time&quot;):</p><pre>birthday = input(&quot;Enter your birthday (DD-MM-YYYY): &quot;)<br>birthday = datetime.strptime(birthday, &quot;%d-%m-%Y&quot;).date()</pre><p>The format string tells Python how to read the input:</p><ul><li>%d → day</li><li>%m → month</li><li>%Y → four-digit year</li></ul><pre>&quot;25-12-2000&quot;  →  strptime()  →  datetime object</pre><h3>Problem 2: I only needed the date, not the time</h3><p>strptime() returns a datetime object, which holds both a date <em>and</em> a time. For a birthday, the time is irrelevant, so .date() pulls out just the date:</p><pre>2000-12-25 00:00:00  →  .date()  →  2000-12-25</pre><h3>Problem 3: finding the next birthday</h3><p>This was the part that made me stop and think.</p><p>My first instinct was to use the birth date directly. But someone born on 25 December 2000 isn’t waiting for 25 December 2000. They’re waiting for 25 December <em>this year</em>.</p><p>So I built a new date from three pieces:</p><pre>current year + birth month + birth day</pre><pre>today = date.today()</pre><pre>next_birthday = date(today.year, birthday.month, birthday.day)</pre><p>If that date has already passed, I move it to next year:</p><pre>if next_birthday &lt; today:<br>    next_birthday = date(today.year + 1, birthday.month, birthday.day)</pre><p>Then subtracting two dates gives a timedelta, and .days gives the number of days between them:</p><pre>(next_birthday - today).days</pre><p>This was the moment datetime stopped feeling like random syntax and became something I could reason through step by step.</p><h3>The Bug I Didn’t See Coming</h3><p>My first version worked, until I thought about people born on <strong>29 February</strong>.</p><p>In a year that isn’t a leap year, this line crashes:</p><pre>date(2027, 2, 29)  # ValueError: day is out of range for month</pre><p>The fix is to catch that error and fall back to 28 February:</p><pre>try:<br>    next_birthday = date(today.year, birthday.month, birthday.day)<br>except ValueError:<br>    next_birthday = date(today.year, 2, 28)</pre><p>It’s a small edge case, but it taught me that working code and <em>correct</em> code aren’t always the same thing.</p><h3>The Complete Program</h3><pre>from datetime import datetime, date<br><br>def birthday_timer():<br>    birthday = input(&quot;Enter your birthday (DD-MM-YYYY): &quot;)<br>    birthday = datetime.strptime(birthday, &quot;%d-%m-%Y&quot;).date()  # convert the string to a datetime object, then keep only the date part<br>    today = date.today()  # get the current date<br>    try:<br>        next_birthday = date(today.year, birthday.month, birthday.day)<br>    except ValueError:<br>        next_birthday = date(today.year, 2, 28)  # 29 February doesn&#39;t exist in non-leap years<br>    if next_birthday &lt; today:<br>        try:<br>            next_birthday = date(today.year + 1, birthday.month, birthday.day)<br>        except ValueError:<br>            next_birthday = date(today.year + 1, 2, 28)<br>    return f&#39;{(next_birthday - today).days} days until birthday&#39;<br><br>print(birthday_timer())</pre><h3>A Common Trap: Mixing Both Import Styles</h3><p>Now that I understood the difference between the module and the class, I could see a mistake I would almost certainly have made.</p><pre>import datetime<br>from datetime import datetime</pre><p>After the second line, the name datetime no longer refers to the module. It refers to the class. So this breaks:</p><pre>datetime.date.today()  # AttributeError</pre><p>The rule I follow now: pick one import style per module and stick with it.</p><h3>The Same Pattern Everywhere</h3><p>Once you see the module → item pattern, you notice it across Python.</p><pre>import math</pre><pre>radius = 5<br>area = math.pi * radius ** 2</pre><p>Here, pi isn&#39;t a function or a class. It&#39;s a <strong>constant</strong> that the math module already defines, so I don&#39;t have to type out an approximation.</p><pre>module → thing inside it<br>datetime → date (a class)<br>math     → pi   (a constant)</pre><p>What lives inside a module can be a class, a function, a constant, or a variable. The access pattern is the same.</p><h3>What Actually Changed</h3><p>Before this, I could <em>write</em>:</p><pre>from datetime import date<br>date.today()</pre><p>Now I can <em>explain</em> it:</p><ul><li>datetime is the module.</li><li>date is a class inside that module.</li><li>today() is a class method that returns today&#39;s date.</li><li>from datetime import date brings that class directly into my program.</li></ul><p>That shift, from memorizing to understanding, is what made Python start to feel less mysterious.</p><p>The most useful habit I picked up is asking one question whenever code confuses me:</p><blockquote><strong><em>What exactly am I working with right now?</em></strong></blockquote><p>A module? A class? A method? An object? A string? A date?</p><p>Answer that, and most of the confusion takes care of itself.</p><p><em>If you’re learning Python too, I’d love to hear which concept finally clicked for you. Drop it in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a0d51a8ad4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Understood Iterators Until I Had to Write One]]></title>
            <link>https://medium.com/@ethansusuluwa/i-understood-iterators-until-i-had-to-write-one-ba0c4a22bbf3?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba0c4a22bbf3</guid>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 23:55:25 GMT</pubDate>
            <atom:updated>2026-09-18T23:55:25.853Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>And what building a Library Management System taught me about the difference.</em></h4><p>One thing I’ve noticed while learning Python is that understanding a concept and being able to <strong>use</strong> that concept are two different things.</p><p>I recently experienced this while building a Library Management System.</p><p>The assignment brought together inheritance, polymorphism, iterators, and encapsulation. None of these concepts were completely new to me. But putting them together was.</p><p>And that was where things got interesting.</p><h3>The Iterator Problem</h3><p>The biggest struggle for me was __iter__() and __next__().</p><p>I understood what they were supposed to do in isolation. I knew that iterators were related to loops. I knew about next(). I knew that StopIteration exists.</p><p>But when I actually had to implement an iterator in a class, my understanding became shaky.</p><p>I hit this while working on a FileLineReader class:</p><pre>class FileLineReader:<br>    def __init__(self, filename):<br>        self.file = open(filename, &quot;r&quot;)<br>    def __iter__(self):<br>        return self<br>    def __next__(self):<br>        return next(self.file)</pre><p>I had to think about what __iter__() should return, what __next__() should do, and how the for loop was actually interacting with both methods.</p><p>That forced me to stop thinking about the syntax and start thinking about the <strong>sequence of events</strong>.</p><p>What happens first? What happens next? What should the next call return? When should the iteration stop?</p><p>The part that surprised me was that I never write raise StopIteration anywhere. The for loop calls __iter__() once, then calls __next__() repeatedly, and stops when StopIteration surfaces. Here it surfaces from next(self.file) on its own and simply travels up through my method. I never call either method myself.</p><p>That was the point where something I had learned theoretically became an actual programming problem.</p><p>It also reminded me of something I’ve come across repeatedly while learning: <strong>the importance of fundamentals cannot be overstated.</strong></p><p>Understanding loops matters when you’re learning iterators. Understanding lists matters when you’re storing borrowed books. Understanding file handling matters when you’re building something like a FileLineReader.</p><p>The concepts don’t stay in their own little boxes. They start connecting.</p><h3>Polymorphism Finally Made Sense</h3><p>Polymorphism was another concept I found difficult to internalise.</p><p>The definition sounded simple enough: different objects can respond differently to the same method call.</p><p>But understanding a definition isn’t the same as developing an intuition for it.</p><p>The analogy that finally helped me was:</p><p><strong>One remote. Three TVs. One button.</strong></p><p>You press the same button on the remote, but each TV responds differently depending on how it is designed.</p><p>That became my mental model. In Python, I could have different objects sharing the same method name, while each object’s implementation produces different behaviour.</p><p>For example, a student and a teacher can both have:</p><pre>borrow_book()</pre><p>but the rules governing that operation can differ. The student might have a borrowing limit of three books, while the teacher’s limit is five. The calling code doesn’t need to know those implementation details.</p><p>That was when polymorphism stopped feeling like a definition I needed to memorise and started feeling like a <strong>design idea</strong>.</p><h3>Inheritance Was More Important Than I Expected</h3><p>The polymorphism problem also made me appreciate inheritance more.</p><p>The Library Management System had a base Book class, with Ebook and PrintBook inheriting from it. There was also a base Member class, with StudentMember and TeacherMember inheriting from it.</p><p>At first, inheritance can look like nothing more than a way to avoid repeating code. But in this project it also created relationships between objects.</p><p>A student <strong>is a</strong> member. A teacher <strong>is a</strong> member. An ebook <strong>is a</strong> book. A printed book <strong>is a</strong> book.</p><p>Once those relationships were clear, overriding methods made more sense too. The code wasn’t just a collection of classes. The classes represented relationships in the system.</p><h3>Encapsulation Became Practical</h3><p>Another concept that became clearer through implementation was encapsulation.</p><p>On the Member class, I used a protected attribute:</p><pre>self._borrowed_books</pre><p>and on the Library class, a private one:</p><pre>self.__library_name</pre><p>Before working on the project, these could easily feel like rules about underscores that Python programmers simply follow.</p><p>The project gave those conventions a purpose. A member’s borrowed books are internal state that the class itself should manage, while the library name is something I chose to expose through a getter and allow changes to through a setter.</p><p>It’s worth being precise about the second one. The double underscore doesn’t make an attribute truly private. Python applies name mangling, so __library_name becomes _Library__library_name and is still reachable from outside if you insist. It signals intent and discourages accidental access rather than enforcing a rule.</p><p>That made encapsulation feel less like terminology and more like <strong>deciding how data is accessed and changed.</strong></p><h3>The Difference Between Knowing and Applying</h3><p>This project changed how I think about learning programming.</p><p>Previously, I could look at a concept and think:</p><p><em>“I understand that.”</em></p><p>But implementation exposed a different question:</p><blockquote><strong><em>Can I use it when the problem requires it?</em></strong></blockquote><p>Those are not always the same thing.</p><p>I could understand what an iterator was but struggle to implement one. I could understand polymorphism but struggle to recognise how to structure it in a real program.</p><p>That distinction is important. Programming isn’t really tested when you can recognise an explanation. It’s tested when you’re sitting in front of a blank editor and have to decide <strong>what should happen next.</strong></p><h3>Thinking Line by Line</h3><p>The technique that helped me most through this project was surprisingly simple: <strong>think line by line.</strong></p><p>When I got stuck, I stopped trying to solve the entire problem at once. Instead:</p><p>What information do I have? What needs to happen first? What should this variable contain? What condition needs to be true? What should happen after that? What should happen on the next iteration?</p><p>That approach turned a complicated problem into a series of smaller decisions.</p><p>And perhaps that’s what I was actually learning. Not just Python syntax, but how to translate a problem into a sequence of logical steps.</p><h3>The Real Lesson</h3><p>The Library Management System didn’t introduce me to programming from scratch. It did something more useful.</p><p>It showed me the gap between <strong>knowing concepts individually and combining them to solve a problem.</strong></p><p>Inheritance, polymorphism, iterators, and encapsulation each make sense on their own. But real programs don’t politely present one concept at a time. They make you combine them.</p><p>That’s where the difficulty, and the learning, really begins.</p><p>I’m starting to see that becoming better at programming isn’t just about learning more Python features. It’s also about becoming better at reasoning:</p><p><strong>What am I trying to achieve?</strong></p><p><strong>What information do I need?</strong></p><p><strong>What should happen first?</strong></p><p><strong>What should happen next?</strong></p><p>And most importantly:</p><p><strong>Why should this line of code exist?</strong></p><p>That last question might be the most useful one I’ve learned to ask so far</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba0c4a22bbf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Python Through the Bugs]]></title>
            <link>https://medium.com/@ethansusuluwa/learning-python-through-the-bugs-3005349424eb?source=rss-ba360388e060------2</link>
            <guid isPermaLink="false">https://medium.com/p/3005349424eb</guid>
            <dc:creator><![CDATA[Ethansusuluwa]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 15:21:15 GMT</pubDate>
            <atom:updated>2026-09-06T15:21:15.415Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A beginner’s honest account of getting stuck, fixing things, and finally understanding what the code was doing.</em></p><p>I sat down with one goal: learn Python by actually building things.</p><p>No tutorials. No passive watching. Just a blank Jupyter notebook and a willingness to figure things out.</p><p>The interesting part wasn’t the programs I built. It was everything that went wrong while building them — and what those mistakes ended up teaching me.</p><h3>The Calculator: print() Is Not return</h3><p>The first challenge was a simple calculator. The logic seemed straightforward: take two numbers, choose an operation, calculate the result, display it.</p><p>Then came functions — and with them, one of the most confusing distinctions I encountered early on: the difference between print() and return.</p><p>At first they felt almost interchangeable. If the answer appears on the screen, isn’t that what matters? Not quite. <strong>print()</strong> displays something and forgets it. <strong>return</strong> sends the value back so the rest of the program can actually use it.</p><p>That distinction became much clearer after getting it wrong. My early attempts calculated the result and immediately threw it away:</p><pre>x1 + x2</pre><pre>return</pre><p>Two lines. Neither useful. The fix was one line that did both:</p><pre>return x1 + x2</pre><p>The calculator also introduced try/except — specifically for division by zero. Instead of letting Python crash, the error was caught and handled cleanly. That felt like real control over the program for the first time.</p><p>The bigger lesson: a function should do one job. Receive inputs, do the work, return the result. Everything else happens outside.</p><h3>Fibonacci: When the Logic Is the Hard Part</h3><p>One lesson that kept coming back throughout this journey is that understanding the logic behind a problem makes finding a solution much easier. Once the logic is clear, the steps follow. Without it, you’re just guessing at syntax.</p><p>This became particularly clear while working on a Fibonacci sequence. I went in thinking it would be straightforward — until I realised that translating the pattern into Python required more thought than expected. Specifically, managing how variables update each loop step was trickier than it appeared.</p><p>The sequence itself is simple: each number is the sum of the two before it.</p><p>0, 1, 1, 2, 3, 5, 8, 13…</p><p>But inside the loop, the order of updates matters completely. Update the wrong variable first and the whole sequence breaks. The fix was a temporary variable to hold the value before it got overwritten — the same logic behind swapping two variables.</p><p>By breaking the problem into smaller steps — calculate, save temporarily, update, repeat — the logic became manageable. That process of decomposition turned out to be more valuable than the solution itself.</p><h3>The Shopping Cart: Dictionaries and the Loop That Wouldn’t Behave</h3><p>The shopping cart introduced dictionaries. The natural instinct was to keep item names and prices in separate lists — but that creates a fragile relationship. If one list changes without the other, everything breaks.</p><p>A dictionary keeps the relationship explicit:</p><pre>cart = {&#39;bread&#39;: 3.6, &#39;mangos&#39;: 6.4}</pre><p>Item as key. Price as value. Always together.</p><p>The bugs here came in layers. An input statement accidentally created a tuple instead of a single value. Prices were treated as strings because they hadn’t been converted to float. The loop ran but nothing accumulated correctly because += was being applied to the wrong type.</p><p>Then came <strong>.items(), </strong>the method that gives both key and value while looping through a dictionary:</p><pre>for item, price in cart.items():<br>    total += price</pre><p>Once that clicked, the rest fell into place. But the real lesson was simpler: if something needs to repeat, it belongs inside the loop. If it only needs to happen once, it belongs outside. Getting that wrong was the source of most of the confusion.</p><h3>File Handling: The completecomplete Problem</h3><p>The file handling program introduced three modes — <strong>r</strong> for read, <strong>w</strong> for write, <strong>a</strong> for append — and a bug that took several attempts to understand.</p><p>The program collected student names in a loop and wrote them to a file. But instead of names, the file kept showing the word complete. Running it multiple times with append mode made it worse:</p><pre>completecomplete</pre><p>Two problems at once. The file-writing operation was inside the loop instead of after it. And the variable being written held its last value, which was<strong> ‘complete’</strong>, the word typed to stop the loop.</p><p>The fix required rethinking the structure entirely. Collect names into a list during the loop. Write the list to the file after the loop ends:</p><pre>students = []<br>while True:<br>     name = input(&#39;Enter name or complete to stop: &#39;)<br>     if name == &#39;complete&#39;:<br>          break<br>     students.append(name + &#39;\n&#39;)<br>with open(&#39;STUDENTS.txt&#39;, &#39;w&#39;) as f:<br>     f.writelines(students)</pre><p>Collect first. Write after. That separation is a principle that showed up in every program, not just this one.</p><h3>What It Actually Taught Me</h3><p>Looking back, the most useful part wasn’t memorising syntax. It was learning how to think through a problem when the code didn’t behave as expected.</p><p>A syntax error tells you Python doesn’t understand what you wrote. A logic error is more interesting: Python understands the code perfectly, but the code doesn’t do what was intended. Both force you to examine your assumptions, and that examination is where the real learning happens.</p><p>Programming is not just about writing code. It is about understanding the problem, developing the logic, and then translating that logic into code. As more complex challenges come up, that approach — logic first — will be the foundation everything else builds on.</p><p>The blank notebook is no longer blank. And the problems that felt impossible at the start now feel like a natural place to begin.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3005349424eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>