Introduction to Google Colab

The vast majority of coding examples in this course will be phrased in the form of a Python notebook. Google Colaboratory (or, just Google Colab) is an online interface for creating Python notebooks. It is extremely convenient because a vast set of Python modules (and, in particular, the modules used in this course) are already installed and, once imported, are ready for use.

Assuming you have a Gmail account and are logged in, click the link provided to run Google Colab notebooks. In the menu bar, choose

File --> New notebook


After doing so, you should see an editable code cell appear in which you can enter a series of Python instructions. Your notebook is automatically linked to the Google Drive associated with your Gmail account. Your Google Colab notebooks are automatically created on your Google Drive in My Drive in a folder named Colab Notebooks. You can treat them as files within Google Colab and perform typical file operations such as renaming, opening, and saving.

Upon entering some basic lines of Python code in the code cell such as:
print('Hello world')
a = 10
print('a =', a)
you can practice executing your code cell in one of several ways:

  1. Click the Play button on the left side of the cell.
  2. Type Alt+Enter: runs the cell and inserts a new, empty code cell immediately following it.
  3. Type Shift+Enter: runs the cell and moves attention to the next cell (adding a new cell if none exists).
  4. Type Cmd/Ctrl+Enter: runs the cell, but control does not advance to the next cell (control remains "in place").
In this course, you will be introduced to several Python modules applicable for data science computations and program implementations:
  • numpy: array operations
  • pandas: dataframe operations
  • scipy.stats: basic statistics
  • matplotlib, pandas, seaborn: visualization
  • scikit-learn: data mining
  • statsmodels: time series analysis

Upcoming units will explain and apply these modules. Before doing so, this unit will first review the basics of the Python programming language.