Skip to main content

Lontras

Lontras Logo

PyPI - Version PyPI - Python Version License: MIT GitHub Actions Workflow Status pre-commit.ci status Codecov CodeFactor Grade


⚠️ This library is under development and has not been released yet

We love pandas and its siblings! They're the industry-standard tools for powerful data manipulation. However, for smaller projects or when minimizing dependencies is paramount, lontras offers a lightweight, pure-Python alternative built on simple dictionaries. Designed for ease of use and direct integration, lontras encourages you to copy and paste its core components into your code. It's the perfect stand mixer for baking smaller data tasks when bringing out the full industrial equipment of pandas is too much.

TLDR;

  • 🤏 Small-scale DataFrame operations? lontras!
  • 🚀 Fast DataFrame loading, no dependencies? lontras!
  • ⚙️ Embed DataFrames in MicroPython? lontras!
  • 🌐 Use DataFrames in the browser (PyScript)? lontras!
  • 🤝 High Pandas compatibility? lontras!
  • 📦 1000x smaller! Pandas+Numpy ~ 120MB; lontras ~ 102KB!
  • ⏱️ Loads 20x faster! Pandas ~ 400ms; lontras ~ 20ms! test script

Table of Contents

Installation

If you prefer to install lontras using pip for easy management and updates, you can do so with the following command:

pip install lontras
# or
uv pip install lontras

This will download and install lontras from the Python Package Index (PyPI).

For lightweight projects where you want to avoid external dependencies, you can simply copy the source file src/lontras/lontras.py into your project directory. This allows you to directly use the library functions from your code without any installation.

Documentation

Check out the API Docs.

Core Functionalities:

Lontras prioritizes simplicity and minimal dependencies. It leverages Python's native dictionaries (via UserDict) to offer core DataFrame and Series functionalities without external libraries.

Data Structures:

  • Series: A one-dimensional array-like structure.
  • DataFrame: A two-dimensional labeled data structure.

Accessing Data:

  • loc and iloc: Access data by label or by index.
  • Label-based access: Access data using standard dictionary-like syntax (e.g., series['label']).
  • Positional access (slicing): Use slices for location-based access (e.g., series[1:3]).
  • Attribute-based access: For convenient access to all values for a given key, use attribute-based access using getattr that dynamically retrieves data based on provided keys or a list of keys.

Modifying Data:

  • Setting values: Modify existing values or add new entries using loc or iloc assignment (e.g., series.loc['label'] = value).
  • Deleting values: Remove entries using del series['label'].
  • Concatenation: Combine Series or DataFrames vertically or horizontally.

Transforming Data:

  • Mapping and applying functions: Apply functions element-wise using map or along axes/indices using apply.
  • Sorting: Sort indexes and values using provided sorting functions.
  • Basic operations: Use standard Python operators (+, -, *, /, //, %, **, comparisons) for element-wise operations.

Data Aggregation and Combination:

  • groupby: Group data based on a column and perform operations within each group (similar to pandas groupby).
  • Join/Merge: Merge two DataFrames based on specific columns (similar to pandas join/merge operations).
  • reduce: Apply a function cumulatively to the elements. Basic reduction functions like max, min, argmax, sum, etc.
  • Leverages Python's built-in statistics module for basic statistical calculations.

Limitations & Trade-offs: (Same as before)

  • No dtype! You ask for a sum, lontras will try to sum and may raise an exception if an unexpcted value is found.
  • Specialized Data Handling: Lontras focuses on core functionalities and doesn't include specialized functions for datetime, strings, or categorical data. However, users can achieve similar behavior through apply and map functions.
  • Statistical Functions: Limited set of statistical functions. Lontras relies primarily on Python's built-in statistics module.
  • Data Import/Export: Supports limited import/export formats. External libraries might be necessary for complex file handling.
  • Missing Data Handling: Doesn't include dedicated functions for handling missing data. Users can implement their own logic using conditional statements or filtering.
  • Multilevel Indexing: Lacks built-in support for multilevel indexing. However, tuple indexes can be used to achieve similar hierarchical structures.
  • Plotting: Currently doesn't include plotting functionalities. External plotting libraries are recommended for visualization.

License

lontras is distributed under the terms of the MIT license.

Metadata

Release files for lontras 0.0.2

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

Source distribution (sdist)

Source distribution for lontras 0.0.2
File Size Uploaded Provenance
lontras-0.0.2.tar.gz 379.1 kB With provenance Details

Built distribution (wheel)

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

Total release size: 393.4 kB

Release files / lontras-0.0.2.tar.gz

Download URL lontras-0.0.2.tar.gz
Size 379.1 kB
Tags Source
SHA-256 checksum
How to use checksums
acfe318a0139a44ecbed3ceb27b76de24669fe01368ade4bf9e836ca28a2f4e7
BLAKE2b-256 checksum
How to use checksums
91353787a28ce135edbdcf34937619411f5036ce596279c85c63bef1695fa61f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 25, 2025.

Transparency log

Release files / lontras-0.0.2-py3-none-any.whl

Download URL lontras-0.0.2-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce4af01cc48371282dae520dbd2b8bec98e46ce3131aaa668adb8eaa0a561131
BLAKE2b-256 checksum
How to use checksums
9b5f14a8aa2f255eff498305c6c0a0b2fe4adb1fc40ad71df1014a0680cdba44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 25, 2025.

Transparency log

Security for lontras 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lontras-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 25, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files Full provenance

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