All the things you can do with Python

The value-added Python offers over and above alternative packages.

Martien Lubberink

Session 1

EAA - ARC Python Primer for Accounting Research

All the things you can do with Python

Video link

Python

  • Python is an interpreted high-level general-purpose programming language.
  • Python was conceived in the late 1980s by Guido van Rossum.
  • The latest version is Python 3.10.0.
  • We will rely on Python version 3.8 via Anaconda.

Why Python?

Why Python?

  • Versatility - wide range of applications
    • Speeds up learning
voctorinox

Why Python?

  • Code readability and code maintenance
jupyter

Why Python?

Why Python?

colab

Why Python?

  • Python input from most popular file formats:
    • Excel
    • csv
    • SAS
    • Stata
    • json
  • Or directly from sources, such as HTML and via APIs

Why Python?

  • Python output:
mastplotlib

Why Python?

  • Python output:
    • Tabular materials to Excel, CSV, LaTeX.
    • Graphs, eg. with Seaborn
scatterplot_matrix

Python and Data Analysis

statsmodels

But most importantly:

Example: resampling data

  • An example of superior date handling capabilities of Python and Pandas
  • We often need to resample data: e.g. from monthly to quarterly, from quarterly to annually. See below data from the RBNZ:
cet2

Example: resampling data

  • An example of superior date handling capabilities of Python and Pandas
  • We often need to resample data: e.g. from monthly to quarterly, from quarterly to annually. See below data from the RBNZ:
cet1

Example: resampling data

  • An example of superior date handling capabilities of Python and Pandas

Code:

cet1_res = cet1[['Net CET1', 'Total RWAs', 'CET1']]
cet1_res = cet1_res.resample('A-JUN').last()

Example: resampling data

print(cet1_res.to_markdown())
Net CET1 Total RWAs CET1
2019 34864 308367 11.306
2020 37080 318554 11.640
2021 41853 320479 13.059