Skip to main content

Partridge

https://img.shields.io/pypi/v/partridge.svg https://img.shields.io/travis/remix/partridge.svg

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. Disconnected data is pruned away according to this graph when reading the contents of a feed. 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.

dependency graph

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)

service_ids = service_ids_by_date[datetime.date(2017, 9, 25)]

feed = ptg.feed(path, view={
    'trips.txt': {
        'service_id': service_ids,
        'route_id': '12300', # 18-46TH AVENUE
    },
})

assert set(feed.trips.service_id) == service_ids
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 service dates

  • 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

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.5.0 (2017-12-22)

  • Easily build a representative view of a zip with ptg.get_representative_feed. Inspired by peartree.

  • Extract out GTFS zips by agency_id/route_id with ptg.extract_{agencies,routes}.

  • Read arbitrary files from a zip with feed.get('myfile.txt').

  • Remove service_ids_by_date, dates_by_service_ids, and trip_counts_by_date from the feed class. Instead use ptg.{read_service_ids_by_date,read_dates_by_service_ids,read_trip_counts_by_date}.

0.4.0 (2017-12-10)

  • Add support for Python 2.7. Thanks @danielsclint!

0.3.0 (2017-10-12)

  • Fix service date resolution for raw_feed. Previously raw_feed considered all days of the week from calendar.txt to be active regardless of 0/1 value.

0.2.0 (2017-09-30)

  • Add missing edge from fare_rules.txt to routes.txt in default dependency graph.

0.1.0 (2017-09-23)

  • First release on PyPI.

Release files for partridge 0.5.0

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

Source distribution (sdist)

Source distribution for partridge 0.5.0
File Size Uploaded
partridge-0.5.0.tar.gz 1.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for partridge 0.5.0
File Interpreter ABI Platform
partridge-0.5.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size:1.7 MB

Release files / partridge-0.5.0.tar.gz

Download URL partridge-0.5.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
1d7bee786c5f97bbd9f8d57ea943c3cdedd14267539d8f08733c3571300b560c
BLAKE2b-256 checksum
How to use checksums
4a0f96f94ef9c1a2a7cf71b844cffb03bc75faa03c69961a5ec0c64c61e1887d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / partridge-0.5.0-py2.py3-none-any.whl

Download URL partridge-0.5.0-py2.py3-none-any.whl
Size 11.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1346d2a2aba336200908b8cfe6b9f9272420be85986b849417a5d4795ec2c839
BLAKE2b-256 checksum
How to use checksums
3326d5aa6f902e303f22fc66f7a028ff0e84f57b1ef76342d3b719fda1d7bcd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

1.1.0

1 release file

1.0.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

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