{"id":"l-pda-1-1","courseId":"python-data-analysis","lang":"en","kind":"intro","summary":"Understand what Python and pandas add to spreadsheet work, meet the Cartwheel data you will analyse, and run your first lines of Python in the browser.","html":"<p>Every month, someone at a company exports a spreadsheet, filters it, fixes the same broken dates, builds the same pivot table and pastes the numbers into a slide. It takes an afternoon, and if the export changes slightly, the numbers quietly go wrong. Python turns that afternoon into a script: you write the steps once, and rerunning them on next month’s file takes seconds.</p>\n<p>This course teaches you exactly the Python a data analyst uses, from zero. No computer science detours: every concept appears because you need it to answer a business question.</p>\n<h2 id=\"sec-1\" tabindex=\"-1\">The company you will work for</h2>\n<p>Cartwheel is an online store selling home and outdoor goods in eight countries: Egypt, the UAE, Saudi Arabia, Jordan, the UK, Germany, the US and Canada. Its data covers January 2024 to December 2025, and it looks like real company data: an <code dir=\"ltr\">orders</code> table, <code dir=\"ltr\">order_items</code> with prices and discounts, <code dir=\"ltr\">products</code>, <code dir=\"ltr\">customers</code>, <code dir=\"ltr\">returns</code>, support tickets and website sessions. There is also <code dir=\"ltr\">orders_messy.csv</code>, an export with mixed date formats, dollar signs in the totals and duplicate rows, which you will clean in Section 3.</p>\n<p>Your running assignment comes from Cartwheel’s head of growth: revenue in Q4 2025 was far higher than any quarter before. Was it Black Friday, more customers, bigger baskets, or a data mistake? By the final section you will answer that with evidence, and every lesson before it gives you one tool you need for the job.</p>\n<h2 id=\"sec-2\" tabindex=\"-1\">How the code in this course runs</h2>\n<p>Code blocks with a <strong>Run</strong> button execute real Python 3.13, with pandas 2.x, in your browser. The Cartwheel CSV files sit in the working directory, so you can open them by name. Output appears only when you <code dir=\"ltr\">print()</code> it. Here is a first taste; you do not need to understand every line yet:</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"python\" data-run=\"python\" data-index=\"0\"><div class=\"code-head\"><span class=\"code-title\">Python</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn code-run\" data-action=\"run\" data-lang=\"python\" data-index=\"0\" aria-label=\"Run this example\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\"/></svg><span>Run</span></button><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">import</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> pandas </span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">as</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> pd</span></span>\n<span class=\"line\"></span>\n<span class=\"line\"><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">orders </span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">=</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> pd.read_csv(</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">\"orders.csv\"</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">)</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">print</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">(</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">len</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">(orders), </span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">\"orders\"</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">)</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">print</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">(orders[</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">\"status\"</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">].value_counts())</span></span></code></pre><div class=\"run-output\" data-run-output=\"0\" hidden></div></div>\n<p>Four lines, and you know Cartwheel has 2,066 orders and how many were delivered, cancelled or returned. By the end of Section 2 you will write lines like these yourself and know exactly what each one does.</p>\n<p>Most lessons end with an exercise. You write code in the editor, press <strong>Check</strong>, and a set of automatic checks tells you which parts are right. Hints are there when you are stuck, and the full solution with an explanation appears once you solve it or ask for it.</p>\n<h2 id=\"sec-3\" tabindex=\"-1\">The loop every analysis follows</h2>\n<p>The course is built around one loop. Each section strengthens one part of it.</p>\n<figure class=\"diagram\"><svg class=\"diagram-svg\" focusable=\"false\" viewBox=\"0 0 700 220\" role=\"img\" aria-labelledby=\"l-pda-1-1-t1\"><defs><marker id=\"arrow-l-pda-1-1-1\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0 L10 5 L0 10 z\" class=\"d-arrowhead\"/></marker></defs>\n  <title id=\"l-pda-1-1-t1\">Six stages in a row: question, load, inspect, clean, analyse, answer, with an arrow from answer back to question. Python basics support every stage; Section 2 covers load and inspect, Section 3 clean, Section 4 analyse and Section 5 answer.</title>\n  <rect class=\"d-box-primary\" x=\"10\" y=\"40\" width=\"96\" height=\"52\" rx=\"10\"/>\n  <text class=\"d-label-strong\" x=\"58\" y=\"71\" text-anchor=\"middle\">Question</text>\n  <rect class=\"d-box\" x=\"128\" y=\"40\" width=\"96\" height=\"52\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"176\" y=\"71\" text-anchor=\"middle\">Load</text>\n  <rect class=\"d-box\" x=\"246\" y=\"40\" width=\"96\" height=\"52\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"294\" y=\"71\" text-anchor=\"middle\">Inspect</text>\n  <rect class=\"d-box-warn\" x=\"364\" y=\"40\" width=\"96\" height=\"52\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"412\" y=\"71\" text-anchor=\"middle\">Clean</text>\n  <rect class=\"d-box-accent\" x=\"482\" y=\"40\" width=\"96\" height=\"52\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"530\" y=\"71\" text-anchor=\"middle\">Analyse</text>\n  <rect class=\"d-box-success\" x=\"600\" y=\"40\" width=\"90\" height=\"52\" rx=\"10\"/>\n  <text class=\"d-label-strong\" x=\"645\" y=\"71\" text-anchor=\"middle\">Answer</text>\n  <path class=\"d-arrow\" d=\"M106 66 L126 66\" marker-end=\"url(#arrow-l-pda-1-1-1)\"/>\n  <path class=\"d-arrow\" d=\"M224 66 L244 66\" marker-end=\"url(#arrow-l-pda-1-1-1)\"/>\n  <path class=\"d-arrow\" d=\"M342 66 L362 66\" marker-end=\"url(#arrow-l-pda-1-1-1)\"/>\n  <path class=\"d-arrow\" d=\"M460 66 L480 66\" marker-end=\"url(#arrow-l-pda-1-1-1)\"/>\n  <path class=\"d-arrow\" d=\"M578 66 L598 66\" marker-end=\"url(#arrow-l-pda-1-1-1)\"/>\n  <path class=\"d-arrow d-dashed\" d=\"M645 92 L645 120 L58 120 L58 96\" marker-end=\"url(#arrow-l-pda-1-1-1)\"/>\n  <text class=\"d-label-muted\" x=\"350\" y=\"140\" text-anchor=\"middle\">a good answer raises the next question</text>\n  <text class=\"d-label-muted\" x=\"235\" y=\"186\" text-anchor=\"middle\">Section 2</text>\n  <text class=\"d-label-muted\" x=\"412\" y=\"186\" text-anchor=\"middle\">Section 3</text>\n  <text class=\"d-label-muted\" x=\"530\" y=\"186\" text-anchor=\"middle\">Section 4</text>\n  <text class=\"d-label-muted\" x=\"645\" y=\"186\" text-anchor=\"middle\">Section 5</text>\n  <path class=\"d-line\" d=\"M140 168 L330 168\"/>\n</svg><figcaption>The analysis loop this course teaches, one section per stage</figcaption></figure>\n<p>Section 1, the one you are starting, gives you the plain Python that every later stage is written in: values, lists, dictionaries, loops, functions, and how to read an error message without panic.</p>\n<aside class=\"callout callout-tip\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5\"/><path d=\"M9 18h6\"/><path d=\"M10 22h4\"/></svg><span><span class=\"callout-kind\">Tip</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Type the code yourself</span></p>\n<p>Reading code feels like understanding it, until you try to write it. When a lesson shows an example, change a number or a column name and run it again. Small experiments teach you more than rereading.</p>\n</aside>\n<p>Next you meet the building blocks of every Python program: values, their types, and the variables that name them.</p>\n","toc":[{"id":"sec-1","text":"The company you will work for","level":2},{"id":"sec-2","text":"How the code in this course runs","level":2},{"id":"sec-3","text":"The loop every analysis follows","level":2}],"takeaways":["Python analysis is a script you can rerun, so next month’s report takes seconds instead of an afternoon.","pandas is the Python library for tables; a DataFrame is its version of a spreadsheet sheet.","Every analysis in this course follows the same loop - question, load, inspect, clean, analyse, answer.","Code blocks with a Run button execute real Python 3.13 in your browser, with the Cartwheel CSV files available."],"further":[{"title":"The Python Tutorial","url":"https://docs.python.org/3/tutorial/index.html"},{"title":"pandas - 10 minutes to pandas","url":"https://pandas.pydata.org/docs/user_guide/10min.html"}],"quiz":[{"q":"<p>Your manager asks for the same sales breakdown on the first Monday of every month. What is the main advantage of doing it in Python rather than by hand in a spreadsheet?</p>","options":[{"text":"Python can open files that are too big for any spreadsheet.","why":"Sometimes true, but Cartwheel’s files open fine in a spreadsheet. Size is not the main gain for a recurring report."},{"text":"The steps are written down as code, so you rerun them on new data and get the same treatment every time.","why":"Correct. A script is a recipe; rerunning it is fast and removes the copy-paste mistakes that creep into manual monthly work."},{"text":"Python produces more accurate arithmetic than a spreadsheet.","why":"Both use the same floating-point arithmetic. The gain is repeatability, not better maths."}],"answer":1},{"q":"<p>Which step of the analysis loop is most often skipped by beginners, and causes the most wrong answers?</p>","options":[{"text":"Loading the file.","why":"You cannot skip loading; nothing works without it, so this rarely causes silent errors."},{"text":"Writing the final chart.","why":"A missing chart makes a report weaker, but it does not make the numbers wrong."},{"text":"Inspecting the data before analysing it.","why":"Correct. Skipping inspection is how blank values, duplicate rows and text-that-should-be-numbers end up silently distorting totals."}],"answer":2},{"q":"<p>What does <code dir=\"ltr\">print()</code> do in the code blocks of this course?</p>","options":[{"text":"It shows a value in the output area under the code.","why":"Correct. Run blocks only display what you print, so wrap anything you want to see in <code dir=\"ltr\">print()</code>."},{"text":"It sends the result to a printer.","why":"The name is historical; in Python <code dir=\"ltr\">print()</code> writes text to the output, not to paper."},{"text":"It saves the value to a file for the next lesson.","why":"Nothing is saved between code blocks; writing files needs functions such as <code dir=\"ltr\">to_csv</code>."}],"answer":0}],"exercise":null,"words":508,"readMinutes":3}