Methods: Python programming for economists

Table of Contents

This website contains the material for the MSc course Methods: Python programming for economists.

This website is under construction for 2025/2026

This year the course is taught by:


Table of Contents


1. Screencasts

For this course a series of screencasts is available. The screencasts can be found on this webpage.

2. Organisation of the course

The course consists of a Career Development part and a python programming part. We discuss both briefly in this section.

2.1. Career Development part of the course

Career development activities (workshops and career events) are part of the course ‘Methods: Python Programming’. The goal of this career development part of the course is to help students from the Master Economics transition into their careers after graduation. The focus is on personal growth and development and provides practical tools to be well prepared for the job application process.

In both semester 1 and semester 2, workshop(s) will be offered by Student Career Services. To pass the course ‘Methods: Python Programming’, you must participate in at least 1 workshop of your choice and at least 1 career event. You will receive a partial grade once you have completed the Python programming part of the course. At the end of the academic year, you will be assessed whether you have met the set criteria of the career development part of the course through a pass or fail. Only with a positive grade for the Python programming part of the course and a pass for the career development part of the course you have passed the course ‘Methods: Python Programming’.

For more information and for an overview of workshops and career events offered throughout the year check the ‘Career Development for MSc Economics’ Canvas page and this file.

2.2. For the python part we will use the following format:

Since we have recorded screencasts, we will not repeat these during the lectures. The lectures are meant for interaction (only).

  • in the python lectures we focus on answering your questions;
  • in order to prepare these answers, it is useful if you create an issue via this link;
    • using the link, create an “issue” where you explain what your question is: what did you try and why did it not work?
      • hence not a something like “I do not know the answer to: Question Calculate the total welfare that this planner can achieve. Denote this value max_welfare.”
      • but “I tried to calculate total welfare in the following way … but then I get the following error …”
      • describing your question like this, helps you better understand what your problem is
      • and it helps us to answer the question in class.
  • for us to be able to prepare these answers, submit the issue on the Friday before the week in which we discuss the topic
    • hence, finish the sections in the week before they are discussed in class
    • if you can solve everything yourself, there is no need to attend the lecture (but you are, of course, welcome to do so)
    • this is one of the advantages of programming: you can see for yourself whether it works or not.
  • alternatively, you can ask questions to the chatbot
    • note that this is still experimental (no rights can be derived etc. etc.)
    • give us your feedback to improve the chatbot

A suggested workflow to learn programming efficiently is:

  • follow the Datacamp courses and make notes of what you learn at Datacamp in a notebook on the jupyterlab server
    • in this way it is easy to refer back to useful code snippets that you see on Datacamp
  • go through the jupyter notebook for the lecture and try to answer the questions
  • if you get stuck with a problem, watch the corresponding screencast for this part. It gives hints and ways to solve the questions in the notebook
  • if you still cannot figure it out, ask the chatbot or create an issue on github to ask us
  • we will answer your questions in class

In September there is a lecture on gender economics. In the lecture Mery will discuss some papers on this topic. There is a notebook where the models discussed are simulated in Python. This notebook is then discussed in a following lecture. The notebook will teach you something about gender economics and Python. At the same time, it shows you what we expect you to do in the final assignment for this course: take an existing theory paper and solve the model in Python and simulate outcomes of the model.

Remark: We have been teaching this course for a couple of years now. Every year there are a number of students who attend the lectures without preparing anything and watch the screencasts without trying to program themselves. We live in a free country and you choose how to spend your time. However, we do feel the need to warn you that this strategy does not work well. You actually end up spending far more time on finishing the course than when you follow the planning we suggest below. The reason is as follows: learning a programming language is frustrating. You learn by making mistakes and then trying to figure out what goes wrong. When you make these mistakes during the semester, you are well covered: we are there to help you. When you make these mistakes for the first time when trying to finish your assignment before the deadline, you are in trouble. We will try to help you but not within an hour, or within a day. And because you need to finish before the deadline, you have to figure everything out by yourself under time pressure. Not a pleasant experience and one you can easily avoid. But the choice is yours.

2.3. Lecture schedule

To be added

2.4. First Lecture

Initial Assignment

Do the following three steps:

  • create a github account on github (you need this account to submit your final assignment)
    • we advise you to do this before Thursday September 25, 2025
  • go to
    • jupyter lab
      • IT suggests that you use the Firefox browser to access jupyter lab
      • sometimes it helps to access jupyter lab with an incognito/private window
      • or –if all else fails– you can use google’s colab
  • create a new python notebook and type the following code in the first cell:
%%bash

git clone https://github.com/janboone/Python-programming-for-economists.git
  • then press the Shift key and Enter key at the same time
  • this creates a folder on the server `Python-programming-for-economists` that contains the material for the course.
  • Note: you can only run this command once. If you run it again, you get an error since the folder already exists.
  • If you want to see the final assignment in jupyter lab, you can also type:
%%bash

git clone https://github.com/janboone/python_assignments

2.5. Datacamp

You can get access to Datacamp via the university website.

From Datacamp, do the following courses:

These courses teach you the basic Python syntax. In the lectures and notebook for the course, we use parts of Python more specific to economics; e.g. commands to solve equations, equilibria etc. These parts of the course complement each other. It is not the case that all Python that we use, you will first see in Datacamp.

It is up to you how to combine the Datacamp courses with the Screencasts. We suggest to finish the Datacamp Intro course first. As there is no economics on Datacamp, some students prefer to start with the screencasts after the Intro. Others prefer to finish more Datacamp courses before they start on the screencasts. Just see what works for you. But make sure you follow the planning above, otherwise you might get lost if you are too far behind and the lectures will not be as useful to you.

Most students like Datacamp to get used to the python syntax. A minority of students really dislike Datacamp. If you do not like it either, you can also read Think Python. You can buy the book or read the free online version. The jupyter notebooks can be found on github. You can clone this repository and work with the notebooks. You can also find some wonderful presentations on Youtube by the author Allen Downey.

2.6. Deadlines

  • The deadline for the final python assignment is: Monday January 5th, 2026.
  • The resit deadline for the python assignment is: Monday May 11th, 2026. Let us know by email that you have submitted your assignment for the resit.
  • Your grade is determined by:
    • a “pass” on the Career Services assignments;
    • final assignment.

Follow the instructions below and on Canvas explaining how to submit an assignment on github and fill in the google form etc.

Also note the rules for the resit of the final assignment in case you submitted an assignment for the first exam opportunity (you cannot discuss/program the same paper twice for your assignment).

2.7. Questions

If you have questions/comments about this course, go to the issues page open a new issue (with the green “New issue” button) and type your question. Use a title that is informative (e.g. not “question”, but “question about the final assignment”). Go to the next box (“Leave a comment”) and type your question. Then click on “Submit new issue”. We will answer your question as quickly as possible.

The advantages of the issue page include:

  • if you have a question, other students may have it as well; in this way we answer the questions in a way that everyone can see it. Also before asking the question, you may want to check whether it was asked/answered before on the issue page
  • we answer your question more quickly than when you email us
  • you increase your knowledge of github!

Only when you need to include privately sensitive information (“my parrot has passed away”), you can send an email.

In order to post issues, you need to create a github account (which you need anyway to follow this course).

Note that if your question is related to another issue, you can react to the earlier issue and leave a comment in that “conversation”.

3. Assignments

For this course there is one final assignment. You can find it in this repository: https://github.com/janboone/python_assignments.

Note that you can do the assignment alone or with at max. one other student (i.e. max group size is 2).

3.1. Submitting assignments

The final assignment is submitted using github classroom:

  • on Canvas we will give you the link to the github repos. with the assignment notebook;
  • instructions on how to work with github classroom can be found here
  • to submit your assignment:
    • do not change the name of the assignment notebook
    • when you submit your final assignment, fill in the google form where the link to the form is on Canvas
    • push the assignment notebook to your team’s github classroom repository

3.2. Final Assignment

  • for the deadlines of the final assignment, see 2.6 above

3.3. what we are looking for

The idea of the final assignment is that you report your findings in a transparent way that can easily be verified/reproduced by others. The intended audience is your fellow students. They should be able to understand the code you write together with the explanations that you give for this code.

The following ingredients will be important when we evaluate your final assignment:

  • Start from a theory (i.e. not empirical) paper; e.g. one you have read for another course.
  • Briefly describe what the paper does and what the main results are.
  • Then formulate a clear and transparent question that cannot be immediately answered by the paper.
    • Extend the paper’s model (a bit) using the fact that you will simulate the model and do not need to provide an analytical solution.
      • note: we do not expect a major extension of the model; just a small change and use simulations to show how results differ due to this adaptation of the model.
      • hint: choose a question/extension where you can show off your programming skills!
  • Briefly motivate why this question is interesting.
  • Give the answer that you find (as a preview).
  • Mention the main assumptions that you need to get this answer.
  • Use \(\LaTeX\) to introduce and explain the model of the paper. Describe the main equations (using \(\LaTeX\)) of the model.
  • When you use information (e.g. a literature reference), create a link to this information. The reader then only needs to click to find the relevant information.
  • Describe your (small) extension of the model.
  • Explain how you move from the analytical equations of the paper to Python code.
  • Use some optimization methods (e.g. agents maximize utility or firms minimize costs).
  • Solve for an equilibrium using Python (using fixed points).
  • Simulate outcomes by using different values for parameters and save the outcomes of the simulations in a pandas dataframe.
  • Explain your code, the reader –think of your fellow students– must be able to easily follow what you are doing.
  • Explain your code in Markdown blocks, not as comments in code blocks.
  • Present graphs of your simulation results using matplotlib.
  • Discuss what the figures show (e.g. \(x\) is increasing in \(y\)) and explain the economic intuition for this relation (between \(x\) and \(y\)).
  • Present a clear conclusion/answer to your question.
  • Finish with a brief discussion of your results.

Remark:

  • you can copy code from the web or an LLM; but
    • make sure that you explain the code that you use so that another student of the course understands it and can use it;
    • give the reference of the code that you copy
    • explain the economics of your results yourself; do not rely on the LLM only.

3.4. resit of final assignment

The resit of the final assignment needs to start from a new paper compared to the one you handed in before. Simply adjusting your first submission based on our feedback will be not be enough.

Otherwise, follow the procedure above on how to submit the assignment and fill in the google form (if you have not done so before). Also send us an email that you submitted the assignment for the resit.

4. Python as programming language

We use Python as programming language. A fair question is: why Python? The non-scientific answer is: because we like it a lot.

You can also check the following links:

Resources for python:

4.1. Jupyter notebooks

Markdown

For the assignment it is useful to know a bit of markdown. You can either google “markdown tutorial” or use one of the following websites:

\(\LaTeX\)

For the python assignment it is useful to familiarize yourself with \(\LaTeX\). Note that you do not need to type a whole document in \(\LaTeX\) (so don’t worry about preambles etc.), you just need to know how to type \(x^2\), \(\alpha,\beta\) or have math displayed like

\begin{equation} a^2 + b^2 = c^2 \end{equation}

Google “latex tutorial” or go to pages like:

and focus on typesetting.

Author: Jan Boone

Validate