Skip to main content

Data cleansing tools for Internal Auditors

Project description

Introduction to Pydit

Pydit is a library of data wrangling tools for use by internal auditors specifically for our typical use cases, see below explanation.

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 due to its main use case I don't commit to keep backward compatibility (see below) 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 all these cleanup and checks (e.g. extract duplicates) snippets are quite important for our work and start to crop up everywhere, often pasted from internet or from recent version used in another script with no consistency or tests.

On the other hand, libraries like pyjanitor do a great job but a) require installation that often is not allowed in your environment b) tend to be compact and non verbose (and use method chaining) and c) are difficult to verify given the high complexity of the library overall.

For internal audit tests, what we really need is very verbose and easy to understand code and outputs, so it is almost self explanatory and easy to review. Most of the time, performance is secondary. We just need it to run a few times for the duration of the audit.

This leads to Pydit following these principles:

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

The auditor should be able to import any individual module to use only those functions in the audit test. That makes it easier to undertand, document and peer-review. Also, it reduces dependencies of future versions of pydit. Typically, we need file the code used as it was ran during the audit.

  1. Functions include verbose logging to explain what is going on. Another feature specifically useful for the Internal Audit use case.

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

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

Pyjanitor is great and its chaining approach is elegant and compact. Definitely one to have in the toolbox. However, I have found it better for documenting the audit test, to check and show all the intermediate steps/results.

  1. The default behaviour is to return a new or a transformed copy of the object and not mutate the input object(s). The "inplace=True" option should be available if feasible.

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

cleanup_column_names(df,inplace=True) # use of inplace, otherwise it returns a new copy

df_deduped=check_duplicates(df, 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.11 (Should work by and large in 3.10, but tests pass on 3.11)
  • pandas
  • numpy
  • openpyxl
  • 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
  • black for style
  • pytest for testing
  • sphinx for documentation in RTD
  • myst_parser is a requirement for RTD too
  • poetry for packaging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydit_jceresearch-0.1.2.tar.gz (47.1 kB view details)

Uploaded Source

Built Distribution

pydit_jceresearch-0.1.2-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file pydit_jceresearch-0.1.2.tar.gz.

File metadata

  • Download URL: pydit_jceresearch-0.1.2.tar.gz
  • Upload date:
  • Size: 47.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/5.15.0-1041-azure

File hashes

Hashes for pydit_jceresearch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ec20f46341d3afcd16c30208cb351722270ab737a552ba4021dbe3464785659b
MD5 6caddc40e377d94a183ea9bdec5a1bb0
BLAKE2b-256 029891ab10636ade17667868ca2509687d74afca0fc6100d5a489b025103c7d5

See more details on using hashes here.

File details

Details for the file pydit_jceresearch-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pydit_jceresearch-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/5.15.0-1041-azure

File hashes

Hashes for pydit_jceresearch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 18014b19a1effffa9b16a6b49acc5698ad89b5629521e27cd2b74621d707fd0b
MD5 8ecf7913851a2b1c4ff36b8cdc2e8aa8
BLAKE2b-256 0e3ec6cc6626d2c49afb40a8cd7e9ca54784aa0c7e14f9fedd92a713e09847b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page