GTFS Kit is a Python 3.10+ library for analyzing General Transit Feed Specification (GTFS) data in memory without a database. It uses Pandas and GeoPandas to do the heavy lifting. (Seems to work fine with Pandas 2 and Pandas 3.)
It can also combine multiple feeds into one via combine_feeds, which unions any number of feeds and deduplicates entities that recur across them, such as shared stops, jointly operated routes, and common shapes.
The functions/methods of GTFS Kit assume a valid GTFS feed but offer no inbuilt validation, because GTFS validation is complex and already solved by dedicated libraries. So unless you know what you’re doing, use the Canonical GTFS Validator before you analyze a feed with GTFS Kit.
Installation
Install it from PyPI with UV, say, via uv add gtfs_kit.
Examples
In the Marimo notebook notebooks/examples.py.
Documentation
The documentation is built via Sphinx from the source code in the docs directory then published to Codeberg Pages at araichev.codeberg.page/gtfs_kit_docs.
Conventions
Throughout GTFS Kit, date means GTFS service date and is encoded as a YYYYMMDD string. In conformance with GTFS, times are HH:MM:SS service-day offsets that can exceed 24 hours. Time-series functions preserve those offsets instead of wrapping them modulo 24 hours. Their date column identifies the service date, while datetime can fall on a later calendar date. For example, 25:30:00 on date 20250101 becomes datetime 2025-01-02 01:30:00 and retains date 20250101. Route, stop, and network stats and timetables use the same date convention. See also gtfs_kit.trips.is_active_trip, which is used in gtfs_kit.routes.compute_route_stats, gtfs_kit.stops.compute_stop_stats, and gtfs_kit.miscellany.compute_network_stats.
‘DataFrame’ and ‘Series’ refer to Pandas DataFrame and Series objects, respectively.
Aggregate service metrics distinguish no service from unknown distance. A group or time bin with no active service has zero distance, duration, and speed. If any contributing trip has unknown distance, aggregate service_distance and service_speed are NA while counts and service_duration remain available. This rule applies to route and network stats and time series, so results remain consistent across aggregation levels and time frequencies.
Notes
This project’s development status is Alpha. I use GTFS Kit at my job and change it breakingly to suit my needs.
This project uses semantic versioning.
I aim for GTFS Kit to handle the current GTFS. In particular, i avoid handling GTFS extensions. That is the most reasonable scope boundary i can draw at present, given this project’s tiny budget. If you would like to fund this project to expand its scope, please email me.
Thanks to MRCagney for periodically donating to this project.
Constructive feedback and contributions are welcome. Please issue pull requests from a feature branch into the develop branch and include tests.
GTFS time is measured relative to noon minus 12 hours, which can mess things up when crossing into daylight savings time. I don’t think this issue causes any bugs in GTFS Kit, but you and i have been warned. Thanks to user Github user derhuerst for bringing this to my attention in closed Issue 8.
With release 10.0.0, i removed the validation module validators.py to avoid duplicating the work of what is now the canonical feed validator (written in Java).
I might require Pandas 3 in the future to take advantage of its new features.
Maintainer Notes
After pushing to master, update the published docs via uv run make -C docs publish-docs
Release files for gtfs-kit 13.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gtfs_kit-13.0.1.tar.gz | 1.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gtfs_kit-13.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.3 MB
Release files / gtfs_kit-13.0.1.tar.gz
| Download URL | gtfs_kit-13.0.1.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c4a58e6f11971d262dbaec08e4f85f727b6609479d07e39a54f2ca4f84eb65a
|
|
BLAKE2b-256 checksum How to use checksums |
26dfd9eb5a90560974c20fbe5542a6484581e3e2e845dbefb615bc4d5d7c8cd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / gtfs_kit-13.0.1-py3-none-any.whl
| Download URL | gtfs_kit-13.0.1-py3-none-any.whl |
|---|---|
| Size | 84.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52677f8615b2751cdce2ee2b7e0acb9240ee8d755ef7a024aff62ea0fd884a77
|
|
BLAKE2b-256 checksum How to use checksums |
8bf234c73c28819ae5113c2b17cb7b5c84b6310258ec5e91ff4379d2cf1160c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|