Logo
Afbeelding

Installing Python

Written by The Audit Analytics | 3 minutes

Python and auditing? Absolutely! More and more auditors are discovering Python to analyze their data. What if you have not worked with python before? Well, I'm not going to give you an extensive Python course —others are much better at that— but I do want to help you get started and point out which packages are useful for the audit.

Installing Python

Why Python?

Excel is great, but sometimes you hit its limits. Large datasets, complex analyses, and repetitive tasks can be quite time-consuming. Python helps to:

  • Process and analyze data efficiently
  • Automate repetitive tasks
  • Identify patterns and anomalies
  • Connect with various data sources (SQL, CSV, APIs, etc.)

And the best part? It's easy to learn!

Installation and Getting Started

To use Python, you need a few things:

  1. Python itself – Download and install it from python.org. During installation, make sure to check the option 'Add Python to PATH' so that you can use Python everywhere on your system. Also, ensure that 'pip' is included so you can easily install additional packages.
  2. A code editor – Jupyter Notebook (via Anaconda) or VS Code are great choices. I always use VS Code to work with any code. It's free, but has a lot of options.
  3. A few handy packages – These packages add extra functionality to python. Open the terminal (on Windows: 'Command Prompt' or 'PowerShell', on Mac/Linux: 'Terminal') and run the following command to install them:
pip install pandas numpy matplotlib seaborn openpyxl pyjanitor

This installs all the mentioned packages at once, so you can get started right away. If you encounter issues, first try python -m ensurepip --default-pip to make sure pip is properly installed. If it still doesn’t work, try updating pip with python -m pip install --upgrade pip.

A Basic Python Script

Below you find a simple script to read a dataset and view the first few rows.

import pandas as pd  # For data processing

# Load data from a CSV file
df = pd.read_csv('audit_data.csv')

# View the first five rows
print(df.head())

Easy, right?

Useful Python Packages for Auditors

There are a lot of Python modules/packages that make your work easier. Of course, in the end you don't need to install these, you can build all these functionalities in Python yourself, but why would you? Below I will mention a few must-haves for the audit analytics:

1. Pandas – Process data like a pro

import pandas as pd

With Pandas, you can easily perform Excel-like operations such as sorting, filtering, and grouping data. Read more about Pandas in this article.

2. NumPy – Work with numbers and statistics

import numpy as np

Perfect for numerical operations such as averages, variances, and standard deviations.

3. Matplotlib & Seaborn – Visualizing data

import matplotlib.pyplot as plt
import seaborn as sns

These tools allow you to create graphs and discover patterns in the data.

4. Openpyxl – Editing Excel files

from openpyxl import load_workbook

Ideal if you want to store audit results directly in an Excel file.

A Simple Audit Check with Python

Let's perform a simple check: looking for duplicate transactions in a dataset.

# Detect duplicate records
duplicates = df[df.duplicated()]

# Display results
print(duplicates)

This piece of code filters all duplicate rows in your dataset. Useful for detecting potentially fraudulent transactions!

So, you've laid the foundation for Python. The next step? Just practice! Start with small analyses and gradually build up. Also, feel free to browse through one of the analyses on The Audit Analytics to understand it better.