Skip to main content
dicekit logo

narlogs

Decorators for logging purposes for all your dataframes.

Install

uv pip install narlogs

Usage

The goal of this project is to make it simple to decorate your dataframe pipeline with some logs. There is a very nice decorator pattern for this and thanks to narwhals we can write utilities for these such that they work on a whole lot of dataframe libraries. The main use case for this is to log useful stats about the dataframe at each step of the pipeline.

import time
import polars as pl
import pandas as pd
from narlogs import print_step

# This is just some function for demo purposes, you can replace it with any function
@print_step
def identity(dataf, t=1):
    time.sleep(t)
    return dataf
    
# When we `.pipe` the function to the polars dataframe it starts printing
pl.read_csv("chickweight.csv").pipe(identity).pipe(identity, t=0.5)

# We get the exact same thing when we pipe it with a pandas dataframe, thanks to narwhals!
pd.read_csv("chickweight.csv").pipe(identity).pipe(identity, t=0.5)

This library also offers a general "callback" function if you want to be more flexible. Maybe you want to create an artifact of some sort or maybe you want to print a sample of the dataframe. Anything a Python function can do, it can do with this callback.

import time
import pandas as pd
import polars as pl
from narlogs import callback

@callback
def print_sample(dataf):
    # You can use narwhals code inside here!
    print(dataf.head(4))

@print_sample
def identity(dataf):
    time.sleep(0.5)
    return dataf
    
# You will now see a sample get printed, in both cases.
pl.read_csv("chickweight.csv").pipe(identity)
pd.read_csv("chickweight.csv").pipe(identity)

Try it live

To learn more, we recommend checking out this Marimo notebook. You can play with narlogs straight from the browser without having to download anything!

Metadata

Release files for narlogs 0.1.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 narlogs 0.1.1
File Size Uploaded
narlogs-0.1.1.tar.gz 6.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for narlogs 0.1.1
File Interpreter ABI Platform
narlogs-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 MB

Release files / narlogs-0.1.1.tar.gz

Download URL narlogs-0.1.1.tar.gz
Size 6.6 MB
Tags Source
SHA-256 checksum
How to use checksums
eea77774442a8f720d26354860f08f0532378d2c36bf8ad1ed6b2f1a208f4af1
BLAKE2b-256 checksum
How to use checksums
8e63d92340a1d25514cc4b81b982867795bf54dd65e8f83d010bfb433dc9654b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.5

Release files / narlogs-0.1.1-py3-none-any.whl

Download URL narlogs-0.1.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac90048130faffd229c90c7381bc6a6ce0776bf20b0ec0bb44d9461355cb9916
BLAKE2b-256 checksum
How to use checksums
774e75b45237c1428426af9dcde9dcea590b7efa9d4a13d9e7fbfd92df0be1d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.5

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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