<?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 Anders Eriksen on Medium]]></title>
        <description><![CDATA[Stories by Anders Eriksen on Medium]]></description>
        <link>https://medium.com/@anderseri?source=rss-18697b003c34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SY0lFPbygGvtIPW9.jpg</url>
            <title>Stories by Anders Eriksen on Medium</title>
            <link>https://medium.com/@anderseri?source=rss-18697b003c34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 01:58:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anderseri/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[Keeping track of your data journalism]]></title>
            <link>https://medium.com/bord4/keeping-track-of-your-data-journalism-378302ecbba0?source=rss-18697b003c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/378302ecbba0</guid>
            <category><![CDATA[data-journalism]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[Anders Eriksen]]></dc:creator>
            <pubDate>Sat, 28 Oct 2017 10:31:24 GMT</pubDate>
            <atom:updated>2017-10-29T15:17:55.580Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cw3eM5qVBL5Kgvvt3ViKlw.jpeg" /></figure><h4>Do you really know how you ended up with those results after analyzing the data from Public Source?</h4><p>Well, often we did not. This is what we knew:</p><ul><li>We had downloaded som data in Excel format.</li><li>We did some magic cleaning of the data in Excel.</li><li>We did some manual alterations of wrong or wrongly formatted data.</li><li>We sorted, grouped, pivoted, and eureka! We had a story!</li></ul><p>Then we got a new and updated batch of the same data. Or the editor wanted to check how we ended up on those numbers, that story.</p><p>Then the problems starts to appear. How could we do the <strong>exact</strong> same analysis over and over again on different batches of data? And how could we explain to curious readers and editors exactly how we ended up with those numbers or that graph?</p><p>We needed a way to structure our data analysis and make it traceable, reusable and documented. This post will show you how. We will not teach you how to code, but maybe inspire you to learn that in the process.</p><p><em>This is the first post on Medium from #bord4 — the editorial development and data journalism team at Bergens Tidende (</em><a href="https://www.bt.no/"><em>bt.no</em></a><em>) in Norway</em></p><h3><strong>Making your folders shine</strong></h3><h4>Organize and stick to it</h4><p>Our first step was to organize our files in a common structure across all projects. We needed a folder for the raw data, one for the output files that our analysis produced, and we needed a place for code and documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*bS68V1OSfu2ZKFTkIMEx1A.png" /><figcaption>A sample of our folder structure . It’s the best. It is great.</figcaption></figure><p>We created a new folder (“thelaboratory”) with a folder for each year, month and the project itself.</p><p>thelaboratory/2017/01/projectname/</p><p>The project folder consists of a data folder for all the raw data files (xls, csv etc).</p><p>There is also an output folder where all files produced by the analysis ends up.</p><h4>The untouchables</h4><p>The files in the data folder are never modified. This is important. You want to keep the files as they were when you downloaded them, got them by e-mail or FOIA’ed them.</p><p>If you need to change them, create a new file (with a script/notebook) with a new name and dump the new file in the output folder.</p><p>That way you can always go back to start and redo your analysis. And you always know that you haven’t altered anything manually in the source files. Because we don’t do that, do we?</p><h4>Know what’s in them</h4><p>The only thing we edit in the data folder are the filenames. This is to make sure we know who provided it to us.</p><p>Often a file you download or get by mail has a name like report123.xlsx . We usually rename that to something like sourcename_20170101_whatitcontains.xslx</p><p>There is one exception: If you get multiple files, like report1.xls , report2.xls etc that later will need to be parsed together, then you should create a subfolder in the data folder with a name following the name standard above and put your files in the folder. That makes it easier to parse all the files later on — they’re all in the same folder.</p><h3>The journalist’s notebook revisited</h3><p>Once you have gathered all your source data files, created your output folder you are ready to interview the data and find the stories.</p><p>Just as a we did 10 or 20 years ago, we want a notebook available when doing interviews, so we can jot down important stuff. How things were said, important quotes, important facts.</p><p>You could of course keep an analog notebook next to your laptop and write down every single operation you do with the Excel-file you got to find a story. But let’s make it a bit more automatic, traceable, reusable and documented.</p><p>Say hello to <a href="http://jupyter.org/">Jupyter Notebook</a>s</p><h4>Documenting for the future you</h4><p>Jupyter is an application that runs in your browser. It makes it easy to code, annotate the code, visualize data, comment and structure your analysis. It is like a living document with code, comments, analysis and graphs all in the same place.</p><p>A jupyter notebook of your project allows you to:</p><ul><li>Document to your self and others how you went about finding that Pulitzer story. So you know how to redo it in a year.</li><li>Automate parts of the data cleaning, reusing code you have created before.</li><li>Repeat the cleaning and analysis in seconds when your source sends you an updated spreadsheet. Without having to do all the 132 steps in Excels manually.</li><li>Be open about how you found those dashing numbers for your story.</li><li>Send the complete research to you editor, lawyer, curious reader or the interwebs.</li></ul><p>Jupyter Notebooks is often used by scientists, especially data scientists.</p><h4>Getting the tools you need</h4><p>To get started with analysis using our folder structure and Jupyter you need to add some animals to your stack.</p><p>First you should get <a href="https://www.anaconda.com/download/">Anaconda</a>: This is called a “data science platform” and is the easiest way to get you started with Jupyter. It includes the programming language <a href="https://www.python.org/">Python</a> and the data science library <a href="http://pandas.pydata.org/">Pandas</a> in addition to Jupyter Notebook app itself.</p><p>Getting all this installed is pretty easy, and there are <a href="http://joshlawman.com/getting-set-up-in-jupyter-notebooks-using-anaconda-to-install-the-jupyter-pandas-sklearn-etc/">several </a>guides out there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8DPFhE5RGTNoOiYfxuhEQ.png" /><figcaption>After installing you should launch the Anaconda Navigator app and press Launch on the Jupyter-button and you are ready to go.</figcaption></figure><p>We are not going to guide you through your first Notebook in this post. If you are not familiar with Jupyter, Python and Pandas you should take your time and follow <a href="http://www.firstpythonnotebook.org/">Ben Welsh’ highly recommended step-by-step guide “First Python Notebook”</a></p><h3>How we structure our notebooks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KdiXD1tkAnUtBvVzFOAZ0A.png" /></figure><p>Every data scientist and journalist probably has their own way of structuring their notebooks. We will show you our preferred way.</p><h4><strong>Split and conquer</strong></h4><p>Putting all your importing, data cleaning and analysis in one single notebook (think of it as a webpage) might get messy. So we often split it in two or more notebooks: cleaning and analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QD8bNpguaEv57WWJuSgoA.png" /><figcaption>Split into multiple notebooks to keep it clean. Import, clean data, visualize and analyze.</figcaption></figure><p>To be able to quickly rerun your scripts in the right order later, numbering them is smart. So you might have these notebooks ( ipynb is the extension of Jupyter notebook files)</p><pre>/myprojects/2010/10/thebigstory/01 Import and clean.ipynb<br>/myprojects/2010/10/thebigstory/02 Analysis.ipynb</pre><h4><strong>The important meta information</strong></h4><p>Don’t mess around later trying to remember where you got the data, from who and when. And maybe a sentence about your data. Add the details to the top of your notebook.</p><p>And of course add a heading so you know what the notebook is all about.</p><h4><strong>Keep it tidy</strong></h4><p>I know, it is not easy once you dig into the analysis, but try to do this:</p><ul><li>Add sub headlines to structure code bits and make your notebook more readable.</li><li>Add Markdown cells with info about what you find out in the process, important notes on why you chose to do your analysis this or that way.</li><li>Keep the code mostly self explanatory: use readable variable names, indent correctly and keep lines short.</li><li>Prefer readable code to code that performs milliseconds faster.</li><li>Comment code that you struggled with, and add links to source of the code bits. (Yes, to <a href="https://stackoverflow.com/">stackoverflow.com</a>)</li><li>Comment the visualizations. What do you see in the graph? What can we conclude (or not conclude) from the graph? What does it tell you?</li></ul><p>Remember: you might create a PDF or website out of the notebook for people to read later. And most importantly: you should be able to read and understand it in yourself two years from now.</p><h4><strong>Track your changes</strong></h4><p>Jupyter Notebook includes a menu item to save a checkpoint which is a version of your notebook at the time of saving. You can use this to save before you start to mess around with your code in innovative ways.</p><p>But as far as we have seen Jupyter only allows for one checkpoint.</p><p>If you (like us) want to keep track of changes and share notebooks among team members, you should check in all the code/notebooks in a version control system like Git. We use use <a href="https://www.github.com/">GitHub</a> for our code.</p><p>The added value of using GitHub is that you can view all your notebooks rendered online. Which is nice for sharing and browsing old notebooks without having to install Jupyter.</p><h3>More inspiration</h3><p>In our next post we’ll get more into detail on importing, cleaning and analyzing data in Jupyter with Pandas. Stay tuned!</p><p>In the mean time you can preview some of our notebooks made for the Data Skup Conference 2017 in Oslo<a href="https://github.com/BergensTidende/dataskup-2017-notebooks"> on our github repo</a>. (code in Python, comments in Norwegian…)</p><p>And of course: do not forget<a href="http://www.firstpythonnotebook.org/"> the great crash course from Ben Welsh in LA Times on making your first Python/Pandas notebook.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=378302ecbba0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bord4/keeping-track-of-your-data-journalism-378302ecbba0">Keeping track of your data journalism</a> was originally published in <a href="https://medium.com/bord4">bord4</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>