Getting Started - Python

Author

ONS Data Science Campus

1 Packages

The purpose of this course is to explore how to structure code, rather than look in depth at analysis or other software packages.

However, due to the case study chosen there are some packages required to run all the code.

As the examples used are basic there is unlikely to be versioning issues. For completeness the dependencies are included.

The main package used is pandas using version 1.1.0. If you have a version newer than this your code will run. If you have older versions of the package the code in the course is not guaranteed to run.

You can check the version of pandas you have by importing it, then checking its version attribute.

import pandas as pd

print(pandas.__version__)

If you would like to to install pandas to the correct version using pip in command line use the following command:

#| eval: false
>pip install pandas==1.1.0

This would give you the correct version of the pandas package for this course.

If you want to use a virtual environment, follow the guide here.

To install all the packages and dependencies in python for this course within your activated virtual environment use the command:

#| eval: false
>pip install -r <path to folder>/requirements.txt

requirements.txt contains the details of all the packages required. It is located in /course_content/.

Exercises

To complete this course you will need to work in Python to edit .py files.

To complete the exercises you will need to run whole files, rather than line by line execution.

Within the folder /course_content/data/ are all of the data files required to complete this course.

Example code, and the code used to complete exercises are contained within the folder /course_content/example_code/.

The exercises are designed across multiple different sets of files, please ensure you are at the correct folder location described in the exercise.

Continue on to Modular Programming in Python