Skip to main content

Lightweight DataFrame logging and pipeline tracking for Pandas workflows

Project description

dfflow

PyPI version Python Versions Tests License

dfflow is a Lightweight Python utility tool for logging, tracking, and debugging Pandas DataFrame workflows.

It provides:

  • Structured DataFrame logging with log levels
  • Step-based pipeline execution
  • Lightweight DataFrame profiling
  • Clean, ML-friendly APIs

Why dfflow?

In real ML projects:

  • DataFrames change at every step
  • Debugging data issues is painful
  • Standard logging libraries do not understand DataFrames

dfflow solves this gap by providing:

  • Visibility into DataFrame transformations
  • Reproducible pipeline execution
  • Minimal overhead with maximum clarity

Installation

pip install dfflow

Requirements

  • Python >= 3.8
  • pandas >= 1.5

Install dependencies

pip install -r requirements.txt

Core Components

  • DFLogger — DataFrame-aware logger

  • FlowPipeline — Step-based DataFrame pipeline

  • Decorators — Lightweight step tracking

  • Cleaning utilities — Common preprocessing helpers

  • Profiling utilities — Quick DataFrame inspection


DFLogger

Class: DFLogger

A DataFrame-aware logger supporting:

  • Log levels (DEBUG, INFO, WARNING, ERROR)
  • Text or JSON logging
  • Log-level filtering using min_level

Parameters

Parameter Description
log_file Output log file path
mode Logging format (text or json)
min_level Minimum log level to record

Logging Methods

Method Description
debug(message: str, df: DataFrame) Logs detailed debugging information
info(message: str, df: DataFrame) Logs standard pipeline progress
warning(message: str, df: DataFrame) Logs potential data issues (e.g., row drops)
error(message: str, df: DataFrame) Logs critical failures or invalid states

Usage

import pandas as pd
from dfflow import DFLogger

df = pd.DataFrame({"A": [1, 2], 
                   "B": [3, 4]})

logger = DFLogger(
    log_file="app.log",
    mode="text",
    min_level="INFO"
)

logger.info("Loaded DataFrame", df)

FlowPipeline

Class: FlowPipeline

FlowPipeline executes DataFrame transformations sequentially while optionally logging each step.

Key Features:

  • Explicit step tracking
  • Clean integration with DFLogger
  • Simple, readable pipeline structure

Methods

Method Description
add_step(name: str, func: Callable) Add a transformation step to the pipeline
run(df: DataFrame) -> DataFrame Executes all steps sequentially and returns the final DataFrame

Usage

import pandas as pd
from dfflow import DFLogger, FlowPipeline, drop_nulls, lowercase_columns

df = pd.DataFrame({"Name": ["Maclin", None],
                   "Age": ["23", None]})

logger = DFLogger()
pipeline = FlowPipeline(logger)

pipeline.add_step("Drop Nulls", drop_nulls)
pipeline.add_step("Lowercase Columns", lowercase_columns)

result = pipeline.run(df)
print(result)

Decorators

log_step is a decorator used to mark DataFrame transformation steps.

Purpose

  • Provides simple step-level tracking
  • Prints completion messages for better visibility
  • Used internally by cleaning utilities but can also be applied to custom functions

Usage

import pandas as pd
from dfflow import log_step

df = pd.DataFrame({"A": [5, 10],
                  "B": [15, 20]})

@log_step("Normalize Columns")
def normalize(df):
    return df/df.max()

normalized_df = normalize(df)
print(normalized_df)

Cleaning Utilities

  • drop_nulls(df) -> Removes rows containing missing values.
import pandas as pd
from dfflow import drop_nulls

df = drop_nulls(df)
print(df)
  • lowercase_columns(df) -> Converts all column names to lowercase.
import pandas as pd
from dfflow import lowercase_columns

df = lowercase_columns(df)
print(df)

Profiling Utilities

Generates a quick summary of a DataFrame.

Includes:

  • Shape
  • Column names
  • Null counts
  • Data types

Usage

import pandas as pd
from dfflow import profile_summary

summary = profile_summary(df)
print(summary)

Examples

Practical usage examples are available in the examples/ directory, including:

  • Basic INFO and DEBUG logging
  • Pipeline execution with logging levels
  • JSON logging
  • Lightweight DataFrame profiling

License

This project is licensed under the MIT License.

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

dfflow-0.2.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dfflow-0.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file dfflow-0.2.0.tar.gz.

File metadata

  • Download URL: dfflow-0.2.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for dfflow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 920d61307be154c2052b34de94313e3ce618008b52b3347e75758dd6a68a0578
MD5 7475f1654f93fd0e92061659bbb09d59
BLAKE2b-256 b729acdbd56407356c4765525e9b0dea440aa9e54e421b63a31a7f071be3fbe3

See more details on using hashes here.

File details

Details for the file dfflow-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dfflow-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for dfflow-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58556b99bafcc5e3ee0e8e0ed0b5ef3cfa1033bda175d72a12eac57a3346acfe
MD5 4475fa9a0e23e33e345b1deafd1ca5c8
BLAKE2b-256 5beb6b0944b9385cdf2e11e49235aab4cba38718cf98457f8799b650efee1d0c

See more details on using hashes here.

Supported by

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