partridge


Namepartridge JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/remix/partridge
SummaryPartridge is python library for working with GTFS feeds using pandas DataFrames.
upload_time2017-12-22 20:47:07
maintainer
docs_urlNone
authorDanny Whalen
requires_python
licenseMIT license
keywords partridge
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Partridge
=========


.. image:: https://img.shields.io/pypi/v/partridge.svg
        :target: https://pypi.python.org/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``. 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.

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

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

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

* Easily build a representative view of a zip with ``ptg.get_representative_feed``. Inspired by `peartree <https://github.com/kuanb/peartree/blob/3bfc3f49ae6986d6020913b63c8ee32582b3dcc3/peartree/paths.py#L26>`_.
* 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.

            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": "partridge", 
    "upload_time": "2017-12-22 20:47:07", 
    "author": "Danny Whalen", 
    "home_page": "https://github.com/remix/partridge", 
    "github_user": "remix", 
    "download_url": "https://pypi.python.org/packages/4a/0f/96f94ef9c1a2a7cf71b844cffb03bc75faa03c69961a5ec0c64c61e1887d/partridge-0.5.0.tar.gz", 
    "platform": "", 
    "version": "0.5.0", 
    "cheesecake_documentation_id": null, 
    "description": "Partridge\n=========\n\n\n.. image:: https://img.shields.io/pypi/v/partridge.svg\n        :target: https://pypi.python.org/pypi/partridge\n\n.. image:: https://img.shields.io/travis/remix/partridge.svg\n        :target: https://travis-ci.org/remix/partridge\n\n\nPartridge is python library for working with `GTFS <https://developers.google.com/transit/gtfs/>`__ feeds using `pandas <https://pandas.pydata.org/>`__ DataFrames.\n\nThe 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.\n\nAt 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.\n\n.. figure:: dependency-graph.png\n   :alt: dependency graph\n\n\nUsage\n-----\n\n.. code:: python\n\n    import datetime\n    import partridge as ptg\n\n    path = 'path/to/sfmta-2017-08-22.zip'\n\n    service_ids_by_date = ptg.read_service_ids_by_date(path)\n\n    service_ids = service_ids_by_date[datetime.date(2017, 9, 25)]\n\n    feed = ptg.feed(path, view={\n        'trips.txt': {\n            'service_id': service_ids,\n            'route_id': '12300', # 18-46TH AVENUE\n        },\n    })\n\n    assert set(feed.trips.service_id) == service_ids\n    assert list(feed.routes.route_id) == ['12300']\n\n    # Buses running the 18 - 46th Ave line use 88 stops (on September 25, 2017, at least).\n    assert len(feed.stops) == 88\n\nFeatures\n--------\n\n-  Surprisingly fast :)\n-  Load only what you need into memory\n-  Built-in support for resolving service dates\n-  Easily extended to support fields and files outside the official spec\n   (TODO: document this)\n-  Handle nested folders and bad data in zips\n-  Predictable type conversions\n\nInstallation\n------------\n\n.. code:: console\n\n    pip install partridge\n\nThank You\n---------\n\nI hope you find this library useful. If you have suggestions for\nimproving Partridge, please open an `issue on\nGitHub <https://github.com/remix/partridge/issues>`__.\n\n\nHistory\n=======\n\n0.5.0 (2017-12-22)\n------------------\n\n* Easily build a representative view of a zip with ``ptg.get_representative_feed``. Inspired by `peartree <https://github.com/kuanb/peartree/blob/3bfc3f49ae6986d6020913b63c8ee32582b3dcc3/peartree/paths.py#L26>`_.\n* Extract out GTFS zips by agency_id/route_id with ``ptg.extract_{agencies,routes}``.\n* Read arbitrary files from a zip with ``feed.get('myfile.txt')``.\n* 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}``.\n\n\n0.4.0 (2017-12-10)\n------------------\n\n* Add support for Python 2.7. Thanks @danielsclint!\n\n\n0.3.0 (2017-10-12)\n------------------\n\n* 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.\n\n\n0.2.0 (2017-09-30)\n------------------\n\n* Add missing edge from fare_rules.txt to routes.txt in default dependency graph.\n\n\n0.1.0 (2017-09-23)\n------------------\n\n* First release on PyPI.\n", 
    "tox": true, 
    "lcname": "partridge", 
    "bugtrack_url": null, 
    "github": true, 
    "coveralls": false, 
    "name": "partridge", 
    "license": "MIT license", 
    "travis_ci": true, 
    "github_project": "partridge", 
    "summary": "Partridge is python library for working with GTFS feeds using pandas DataFrames.", 
    "split_keywords": [
        "partridge"
    ], 
    "author_email": "daniel.r.whalen@gmail.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2017-12-22T20:47:11", 
            "comment_text": "", 
            "python_version": "3.6", 
            "url": "https://pypi.python.org/packages/33/26/d5aa6f902e303f22fc66f7a028ff0e84f57b1ef76342d3b719fda1d7bcd9/partridge-0.5.0-py2.py3-none-any.whl", 
            "md5_digest": "6add100da9e250adb6d8e9bb4ad1286d", 
            "downloads": 0, 
            "filename": "partridge-0.5.0-py2.py3-none-any.whl", 
            "packagetype": "bdist_wheel", 
            "path": "33/26/d5aa6f902e303f22fc66f7a028ff0e84f57b1ef76342d3b719fda1d7bcd9/partridge-0.5.0-py2.py3-none-any.whl", 
            "size": 11894
        }, 
        {
            "has_sig": false, 
            "upload_time": "2017-12-22T20:47:07", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/4a/0f/96f94ef9c1a2a7cf71b844cffb03bc75faa03c69961a5ec0c64c61e1887d/partridge-0.5.0.tar.gz", 
            "md5_digest": "84aea591ea4b93b02d20effa425c7cf1", 
            "downloads": 0, 
            "filename": "partridge-0.5.0.tar.gz", 
            "packagetype": "sdist", 
            "path": "4a/0f/96f94ef9c1a2a7cf71b844cffb03bc75faa03c69961a5ec0c64c61e1887d/partridge-0.5.0.tar.gz", 
            "size": 1673667
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}