Skip to main content

Introduction to Pydit

Pydit is a library of data wrangling tools aimed to internal auditors
specifically for our use cases.

This library is also a learning exercise for me on how to create a package, build documentation & tests, and publish it.
Code quality varies, and I don't commit to keep backward compatibility (see below how I use it) So, use it at your own peril!
If, despite all that, you wish to contribute, feel free to get in touch.

Shout out: Pydit takes ideas (and some code) from Pyjanitor, an awesome library.
Check it out!

Why a dedicated library for auditors?

The problem Pydit tries to solve is that a big part of our audit tests have to do with basic data quality checks (e.g. find duplicates or blanks) as they may flag potential fraud or systemic errors.

But to do those check I often end up pasting snippets from internet or reusing code from previous audits with no consistency or tests done.

What I really need is:

a) easy to review code, both code and execution (even for non-programmers)

b) portable, minimal dependencies, pure python, drop-in module ideally.

c) performance is ultimately secondary to readability and repeatability.

Pydit follows these principles:

  1. Functions should be self-standing with minimal imports/dependencies.

The auditor should be able to import or copy->paste only a specfic module into the project to perform a particular the audit test. That makes it easier to undertand, customise, review. Plus, it removes dependencies of future versions of pydit. In any case, we need to keep on file the actual code used to perform the test.

  1. Functions should include verbose logging, short of debug level.

  2. Focus on documentation, tests and simple code, less concerns on performance.

  3. No method chaining, in interest of source code readability.

While excellent libraries like Pyjanitor are great and its method chaining approach is elegant, my experience has been that the good old "step by step" approach works better for documenting the test and explaining it to reviewers. Plus, pyjanitor adds those methods directly to pandas objects which adds some complexity/coupling to the code, and has more library dependencies given than Pydit, given its quite extensive functionality.

  1. Returns a new transformed copy of the object, code does not mutate the input object(s).

Quick start

import pandas as pd
from pydit import start_logging_info  # sets up nice logging params with rotation
from pydit import profile_dataframe  # runs a few descriptive analysis on a df
from pydit import cleanup_column_names  # opinionated cleanup of column names


logger = start_logging_info()
logger.info("Started")

The logger feature is used extensively by default, aiming to generate a human readable audit log to be included in workpapers.

I recommend importing individual functions so you can copy them locally to your project folder and just change the import command to point to the local module, that way you freeze the version and reduce dependencies.

df = pd.read_excel("mydata.xlsx")

df_profile = profile_dataframe(df)  # will return a df with summary statistics

# you may realise the columns from excel are all over the place with cases and
# special chars

df_clean = cleanup_column_names(df)

df_deduped = check_duplicates(
    df_clean,
    columns=["customer_id", "last_update_date"],
    ascending=[True, False],
    keep="first",
    indicator=True,
    also_return_non_duplicates=True,
)

# you will get a nice output with the report on duplicates, retaining the last
# modification entry (via the pre-sort descending by date) and returning
# the non-duplicates,
# It also brings a boolean column flagging those that had a duplication removed.

Requires

  • python >=3.13
  • pandas
  • numpy
  • matplotlib (for the ocassional plot, e.g. Benford)

Installation

pip install pydit-jceresearch

(not available in anaconda yet)

Documentation

Documentation can be found here

Dev Install

git clone https://github.com/jceresearch/pydit.git
pip install -e .

This project uses:

  • pylint for linting
  • ruff for style
  • pytest for testing
  • sphinx for documentation in RTD
  • myst_parser is a requirement for RTD too

Metadata

Release files for pydit-jceresearch 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydit-jceresearch 0.2.1
File Size Uploaded
pydit_jceresearch-0.2.1.tar.gz 184.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydit-jceresearch 0.2.1
File Interpreter ABI Platform
pydit_jceresearch-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 245.9 kB

Release files / pydit_jceresearch-0.2.1.tar.gz

Download URL pydit_jceresearch-0.2.1.tar.gz
Size 184.8 kB
Tags Source
SHA-256 checksum
How to use checksums
287f9bc8e749b7584b8fbebcd56c90d05d171f96efe070e45904fedd86ff2f45
BLAKE2b-256 checksum
How to use checksums
5c37a7c1a0f62bdc7d8a3d39ef0eb8a77c3a542b640733d99666764e21532c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pydit_jceresearch-0.2.1-py3-none-any.whl

Download URL pydit_jceresearch-0.2.1-py3-none-any.whl
Size 61.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79456b99d697ba3c52485a32849933a1eb900ebdf5221495fed051efeacf0428
BLAKE2b-256 checksum
How to use checksums
f78b704248c2170ce63615dd2f79db875f864ff178354554103618bc4f71fabe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page