Data Adventure #1: Python Overview

Posted on 06/12/19 by LA Counts

Welcome to an introduction to the tools we'll use in LA Counts data instructables! This introduction is for anyone interested in analyzing data and creating data visualizations. You won't need any special skills or programming experience, only a curiosity about using data for advocacy. We also will use only freely available tools so you can easily analyze your own datasets.

Python, by xkcd

Tools for Data Analysis

In these instructables we take a "data science" approach to analyzing data. This means we are interested in using software to extract social scientific insights. Some of the analyses you can do at the start might be familiar to you from working in Microsoft Excel. However, the difference with software is you can so do much more! Here are some things you'll learn to do with a data science perspective in these instructables:

  • Extract insights about your local neighborhood through data
  • Learn how to use data analyses to Analyze datasets using statistical techniques
  • Generate charts to use in reports and presentations

What is Python? Why is it good for data science?

Good Question! There are numerous programming languages out there.

  • Python is a scripted programming language. That means you can edit the code up to the point you execute it.
  • Python is a free programming language suitable for beginners.
  • Python is well-supported by an online community that has developed a range of libraries (or modules) for analyzing data.
  • For more information on Python, please see the FAQ on python.org.

Jupyter Notebooks

You're reading this text in a Jupyter Notebook. Jupyter Notebooks are like a Google doc that can hold blocks of text, like the one you're reading. Other blocks have code you can edit, like the one below this text block. For example, when you press the "play" button below, the Python code in that section is executed.

The code block below executes a classic "hello world" program, which just stores a string to a variable (called variable) and then prints it out. Pretty cool, right?

If you want to learn more about Python, you can check out "Automate the Boring Stuff with Python" – a free online textbook. But you don't need to be an expert programmer to use Python! All our guides will show you how to analyze data and generate graphs by just changing a few lines of code.

"Hello, World" is a classic first exercise in programming. All the code below does is print out the text between the quotes. If you want to modify these examples, you can just click on the code blocks and change the code, then run it! In fact, you can change the code below right now. Why don't you try editing the text in the quotes "hello world"? When you run the code again, you'll notice it prints out your new text!


Try it Yourself »

Different code blocks also remember the variables you set in earlier code blocks in the same document. For example, if you wanted to print your variable out below, without setting the variable again, you could! The below code prints the string out twice, with a space between each:


Try it Yourself »

So that's it!

In this instructable, you've learned a little about the programming language Python, the integrated development environment (IDE) of Jupyter Notebooks, and the libraries we'll be using to analyze data. After you sign up for a plot.ly account, you may want to read our next instructable on finding a dataset, or jump right into one of our instructables for data analysis.

comments powered by Disqus