Partridge is python library for working with GTFS feeds using pandas DataFrames.
Project description
Partridge
Partridge is python library for working with GTFS feeds using pandas DataFrames.
The implementation of Partridge is heavily influenced by our experience at Remix ingesting, analyzing, and debugging thousands of GTFS feeds from hundreds of agencies.
At the core of Partridge is a dependency graph rooted at trips.txt. When reading the contents of a feed, disconnected data is pruned away according to this graph. The root node can optionally be filtered to create a view of the feed specific to your needs. It’s most common to filter a feed down to specific dates (service_id), routes (route_id), or both.
Usage
import datetime
import partridge as ptg
path = 'path/to/sfmta-2017-08-22.zip'
service_ids_by_date = ptg.read_service_ids_by_date(path)
feed = ptg.feed(path, view={
'trips.txt': {
'service_id': service_ids_by_date[datetime.date(2017, 9, 25)],
'route_id': '12300', # 18-46TH AVENUE
},
})
assert set(feed.trips.service_id) == service_ids_by_date[datetime.date(2017, 9, 25)]
assert list(feed.routes.route_id) == ['12300']
# Buses running the 18 - 46th Ave line use 88 stops (on September 25, 2017, at least).
assert len(feed.stops) == 88
Features
Surprisingly fast :)
Load only what you need into memory
Built-in support for resolving calendar days
Built on pandas DataFrames
Easily extended to support fields and files outside the official spec (TODO: document this)
Handle nested folders and bad data in zips
Predictable type conversions, by default
Installation
pip install partridge
Thank You
I hope you find this library useful. If you have suggestions for improving Partridge, please open an issue on GitHub.
History
0.1.0 (2017-09-23)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file partridge-0.1.0.tar.gz
.
File metadata
- Download URL: partridge-0.1.0.tar.gz
- Upload date:
- Size: 314.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7d332d357b4add92f23ec6c4762a7ad9e3d3c617a719a2700f5cf43d4a1416a |
|
MD5 | 3abd15d72600027840f9cd73b556b0a1 |
|
BLAKE2b-256 | 08b9c7052de201d3f8b8c9cd1515d99fedf59b5389c942c873093634902b273a |
File details
Details for the file partridge-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: partridge-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a658cd59bf685764830b44cb425bbb99f156168c598c7bffac0b5e1e4a829d23 |
|
MD5 | 5082675b085313f88f88c20033a34e10 |
|
BLAKE2b-256 | 92cec006298e7c954e5430e31c7bdd169d5d74767d2e373a5c018a863db7adce |