Skip to main content

GataFrame

CI PyPI Python

GataFrame is a lightweight Python library built around DuckDB relations. It adds a dataframe-style wrapper plus file and database read-write helpers for tabular and geospatial workflows.

The PyPI distribution is named ga-gataframe; the import package is named gataframe.

Installation

python -m pip install ga-gataframe

Development and test tools are available as extras:

python -m pip install -e ".[test]"
python -m pip install -e ".[dev]"

Optional parallel cleanup helpers are available with:

python -m pip install -e ".[parallel]"

Quick Start

import pandas as pd

from gataframe import connect

engine = connect(extensions=None)

gf = engine.read(pd.DataFrame({"id": [1, 2], "value": [10, 20]}))
result = gf.withColumn("double_value", "value * 2").filter("double_value > 20").toPandas()

assert result["double_value"].tolist() == [40]

engine.close()

GataFrame

GataFrame wraps a duckdb.DuckDBPyRelation and keeps operations chainable. Most methods return a new GataFrame unless inplace=True is passed.

import pandas as pd

from gataframe import connect

engine = connect(extensions=None)
gf = engine.read(pd.DataFrame({"a": [1, 2], "b": [3, 4]}))

out = (
    gf.withColumn("total", "a + b")
    .renameColumn("total", "sum_ab")
    .replaceColumn("sum_ab", "sum_ab * 10")
    .select("a", "sum_ab")
)

assert out.columns == ["a", "sum_ab"]

Common methods include:

  • withColumn(name, expression) and replaceColumn(name, expression)
  • renameColumn(old, new) and excludeColumn(*columns)
  • select(*columns), filter(expression), and limit(n)
  • createTable(...), createView(...), dropTable(...), and dropView(...)
  • toPandas(), toGeoPandas(...), and toPandasOrGeoPandas(...)

Engine

Engine owns the DuckDB connection and handles input/output.

from gataframe import connect

engine = connect(extensions=None, file_based=False)

gf = engine.read("data.csv", header=True)
engine.write(gf, "out.parquet", mode="overwrite")

engine.close()

Engine.read(...) also accepts in-memory dictionary and list-of-dictionaries sources, converting them to DuckDB relations through pandas.

Supported readers and writers are inferred from file extensions where possible: CSV, JSON, Parquet, GeoParquet, GeoJSON, GeoPackage, Shapefile, SQLite, and PostgreSQL connection URLs.

Reader format aliases are also supported and normalized automatically:

  • CSV: csv, txt, tsv
  • Parquet: parquet, pq
  • GeoParquet: geoparquet, gpq
  • GeoPackage: gpkg, geopackage
  • Shapefile: shp, shapefile
  • JSON: json
  • GeoJSON: geojson
  • SQLite files: sqlite, sqlite3, db, db3

DuckDB extensions are loaded only when requested by the caller or needed by a specific geospatial/database operation.

API Summary

  • connect(logger=None, extensions=None, options=None, file_based=False, file=None)
  • read(engine, source, format=None, pre_limit=None, limit=None, ...)
  • write(engine, df, destination, mode="overwrite", partitionBy=None, ...)
  • Engine.connect(...)
  • Engine.read(source, format=None, ...)
  • Engine.write(df, destination, mode="overwrite", ...)
  • GataFrame.withColumn(...), replaceColumn(...), renameColumn(...)
  • GataFrame.select(...), filter(...), limit(...), union(...)
  • GataFrame.pandasDType
  • GataFrame.toPandas(), toGeoPandas(...), and toPandasOrGeoPandas(...)

Development

GataFrame supports Python 3.10 and newer.

python -m pip install -e ".[dev]"
python -m compileall -q src
python -m pytest --cov=gataframe --cov-report=term-missing
ruff format --check .
ruff check .
mypy
python -m pip check
python -m build
python -m twine check dist/*

GitHub Repository Setup

This project is prepared for the future repository andreagemma/gataframe.

  1. Create the empty repository on GitHub.
  2. Initialize the local repository if needed and push the project to main.
  3. Confirm the CI workflow passes on GitHub.
  4. Configure the PyPI Trusted Publisher for project ga-gataframe, owner andreagemma, repository gataframe, workflow release.yml, and environment pypi.

Releases

src/gataframe/_version.py is the only version source. To publish a release:

  1. Update __version__ in _version.py and commit the release changes.
  2. Push main and wait for CI to pass.
  3. Run the Create release GitHub Actions workflow. With no override it creates the v<version> tag, creates release notes, and dispatches the build and PyPI publication workflow.

PyPI versions are immutable. Increment _version.py before publishing different content.

License

GataFrame is distributed under the MIT License. See LICENSE.

Release files for ga-gataframe 0.1.5

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

Source distribution (sdist)

Source distribution for ga-gataframe 0.1.5
File Size Uploaded
ga_gataframe-0.1.5.tar.gz 74.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ga-gataframe 0.1.5
File Interpreter ABI Platform
ga_gataframe-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 122.9 kB

Release files / ga_gataframe-0.1.5.tar.gz

Download URL ga_gataframe-0.1.5.tar.gz
Size 74.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3174e84c3e1843696d2e588b672034f0b0b2b6b3af4c03fc9832f5dfe49ab00d
BLAKE2b-256 checksum
How to use checksums
803b576e5b08fce30faef0ade9bd8b068db2941a3f6298392caa117cf1194d0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 24, 2026.

Transparency log

Release files / ga_gataframe-0.1.5-py3-none-any.whl

Download URL ga_gataframe-0.1.5-py3-none-any.whl
Size 48.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0b28d7db1efcb3c0bca66d0cd8b25691eeecf7c8022b3ad7e160509ac785dcb
BLAKE2b-256 checksum
How to use checksums
83074c75677644044fc00cb430c55ac1cb87ab2b3c94613e6b43e26bda14bdfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

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