Tag Archives: functions

VIDEO PLAYLIST: An introduction to Python for data journalism and scraping

Python is an extremely powerful language for journalists who want to scrape information from online sources. This series of videos, made for students on the MA in Data Journalism at Birmingham City University, explains some core concepts to get started in Python, how to use Colab notebooks within Google Drive, and introduces some code to get started with scraping.

Continue reading

VIDEO: Understanding API jargon for data journalists

Yesterday I shared a video introducing APIs for data journalists. In this video — first made for students on the MA in Data Journalism at Birmingham City University and shared as part of a series of video posts — I explain some of the jargon you’re likely to come across when using an API.

That includes ‘functions’ and ‘methods’ that allow you to request certain types of data; ‘arguments’ that allow you to specify what you want data about, or what format; and API ‘keys’ that act as passwords to access the data.

Links mentioned in the video:

How to: fix spreadsheet dates that are in both US and UK formats

640px-Date_format_by_country.svg

This map by Artem Karimov shows which countries use which data formats

It’s quite common when working with Google Sheets to have data set to US format (Month-Day-Year) without realising it. This is because Google will format your dates based on what ‘locale’ or language you have set – and the default is US English.

Instructions on how to change that are here – but what if it’s too late? What if you’ve already inputted or imported data which, when updated to a different format, will make it the wrong date? Continue reading

Coding for journalists: 10 programming concepts it helps to understand

If you’re looking to get into coding chances are you’ll stumble across a raft of jargon which can be off-putting, especially in tutorials which are oblivious to your lack of previous programming experience. Here, then, are 10 concepts you’re likely to come across – and what they mean.

1. Variables

cat in a box

Variables are like boxes which can hold different things at different times. Image by Wolfgang Lonien.

A variable is one of the most basic elements of programming. It is, in a nutshell, a way of referring to something so that you can use it in a line of code. To give some examples:

  • You might create a variable to store a person’s age and call it ‘age’
  • You might create a variable to store the user’s name and call it ‘username’
  • You might create a variable to count how many times something has happened and call it ‘counter’
  • You might create a variable to store something’s position and call it ‘index’

Variables can be changed, which is their real power. A user’s name will likely be different every time one piece of code runs. An age can be added to at a particular time of year. A counter can increase by one every time something happens. A list of items can have other items added to it, or removed. Continue reading