Skip to main content
Daffodil logo

Python Daffodil

Daffodil (DAtaFrames For Optimized Data Inspection and Logical processing) gives Python fast, lightweight 2-D data tables. A table is a list of rows, and each row is a plain Python list. Use it where data arrives and is processed row by row: reading files, building records, cleaning, reshaping, and writing them out again.

Documentation: https://raylutz.github.io/daffodil/

Status: alpha, and used in production for several years. The changes of each release are in the changelog.

Install

pip install daffodil

Python 3.10 or later. Daffodil is pure Python. pandas and NumPy are needed only to convert to and from them.

The data model

The Daffodil data model: lol, hd, kd and dtypes

The rows are kept in lol, a list of lists. The column names are kept once, in the header dict hd, which maps each name to its position. A table can have a keyfield, a column whose values identify the rows, and then the key dict kd maps each key to its row. A cell can hold any Python object: text, a number, a list, a dict, or even another table.

Quick start

from daffodil.daf import Daf

daf = Daf(cols=['id', 'item', 'qty'], keyfield='id')
daf.append({'id': 'a1', 'item': 'pen', 'qty': 3})
daf.append(['b2', 'ink', 10])

daf['b2']                     # the row with key 'b2'
daf[0]                        # the first row
daf[:, 'qty']                 # the qty column
daf['b2', 'qty'].to_value()   # 10
daf.select_where(lambda row: row['qty'] > 5)
print(daf)                    # a Markdown table

Why Daffodil

  • Adding a row is cheap. It is appended to a Python list. pandas has no cheap way to add a row, so code that uses it often collects the rows first and converts them at the end.
  • No conversion. The data stays the Python objects you put in, so there is no cost to get it in or out.
  • A selection shares the rows. Selecting rows copies no data, and lookups by key are dict lookups.
  • Mixed data is fine. A column can mix text, numbers and empty cells, and nothing is coerced to NaN or to a common type.
  • Tables print as Markdown, ready for a terminal or a report, and can be read back.
  • Small and pure Python, so it starts fast, which matters in short-lived cloud functions.

For heavy math over whole numeric columns, pandas, NumPy or Polars are faster. Build and clean the data as rows in Daffodil, then hand the numeric columns over with to_pandas_df() or to_numpy(). The documentation compares the two, with measurements.

Learn more

Questions and ideas are welcome as GitHub issues. Daffodil is released under the MIT license.

Metadata

Release files for daffodil 0.7.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 daffodil 0.7.2
File Size Uploaded
daffodil-0.7.2.tar.gz 370.9 kB Details

Built distribution (wheel)

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

Total release size: 570.3 kB

Release files / daffodil-0.7.2.tar.gz

Download URL daffodil-0.7.2.tar.gz
Size 370.9 kB
Tags Source
SHA-256 checksum
How to use checksums
270c6b89d173ccde4a9340150d48e9501b6dcb6cfee75544415b261b1941bb0e
BLAKE2b-256 checksum
How to use checksums
dda5f511c75790e40a5675a470631e2e92d6deba9fe244b54a7fbdb0bb7b6f48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / daffodil-0.7.2-py3-none-any.whl

Download URL daffodil-0.7.2-py3-none-any.whl
Size 199.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c0d37a4645cf0bdd7386e0a6618bad150a6d334e672b47a17980fa06bd7353b
BLAKE2b-256 checksum
How to use checksums
cd6bb0439f67af9ce1bdaeed44fb4f52a7b065c8d01de6117b1cdb9fb61a23d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.8.1

2 release files

0.8.0

2 release files

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.13

2 release files

0.5.10

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

1 release file

0.3.0

2 release files

0.2.2

1 release file

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