Skip to main content

Partridge is python library for working with GTFS feeds using pandas DataFrames.

Project description

=========
Partridge
=========


.. image:: https://img.shields.io/pypi/v/partridge.svg
:target: https://pypi-hypernode.com/pypi/partridge

.. image:: https://img.shields.io/travis/remix/partridge.svg
:target: https://travis-ci.org/remix/partridge


Partridge is python library for working with
`GTFS <https://developers.google.com/transit/gtfs/>`__ feeds using
`pandas <https://pandas.pydata.org/>`__ DataFrames.

The implementation of Partridge is heavily influenced by our experience
at `Remix <https://www.remix.com/>`__ 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.

.. figure:: dependency-graph.png
:alt: dependency graph


Usage
-----

.. code:: python

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
------------

.. code:: console

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 <https://github.com/remix/partridge/issues>`__.


=======
History
=======

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

partridge-0.2.0.tar.gz (314.8 kB view details)

Uploaded Source

Built Distribution

partridge-0.2.0-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file partridge-0.2.0.tar.gz.

File metadata

  • Download URL: partridge-0.2.0.tar.gz
  • Upload date:
  • Size: 314.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for partridge-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a7b9f387783c445b02b07b9f15970a7ff72c4b1e0004831e1b12320d64b9bffc
MD5 3dfe07c8cbfb81d627cccf7f6f402e01
BLAKE2b-256 0b4748a20946599d96f0ccf66efeaf3a75d1abbcbd95986e710d5ed6979fb371

See more details on using hashes here.

File details

Details for the file partridge-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for partridge-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 242e47f140431b4d713d47055df0b0cd3ee7ca5d4dfc3163cac12a049b7aa509
MD5 6973be9e49225eb2033f481e18d348d6
BLAKE2b-256 3fc457ed2746330a4408c71a4da3b357bd6e7b02d0448f43f3539f3ea1ff8706

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page