{ "info": { "author": "David Schoonover", "author_email": "dsc@less.ly", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "nesting\r\n=======\r\n\r\nThis module is a Python port of the \r\n`nest operator `__ from Mike Bostock's `d3.js `__.\r\n\r\n\r\nNest allows elements in an array to be grouped into a hierarchical tree structure;\r\nthink of it like the GROUP BY operator in SQL, except you can have multiple levels of\r\ngrouping, and the resulting output is a tree rather than a flat table. The levels in\r\nthe tree are specified by key functions. The leaf nodes of the tree can be sorted by\r\nvalue, while the internal nodes can be sorted by key. An optional rollup function will\r\ncollapse the elements in each leaf node using a summary function. The nest operator\r\n(the object returned by d3.nest) is reusable, and does not retain any references to the\r\ndata that is nested.\r\n\r\nFor example, consider the following tabular data structure of Barley yields, from\r\nvarious sites in Minnesota during 1931-2:\r\n\r\n>>> yields = [\r\n {\"yield\": 27.00, \"variety\": \"Manchuria\", \"year\": 1931, \"site\": \"University Farm\"},\r\n {\"yield\": 48.87, \"variety\": \"Manchuria\", \"year\": 1931, \"site\": \"Waseca\"},\r\n {\"yield\": 27.43, \"variety\": \"Manchuria\", \"year\": 1931, \"site\": \"Morris\"}, \r\n {\"yield\": 43.07, \"variety\": \"Glabron\", \"year\": 1931, \"site\": \"University Farm\"},\r\n {\"yield\": 55.20, \"variety\": \"Glabron\", \"year\": 1931, \"site\": \"Waseca\"},\r\n {\"yield\": 16.18, \"variety\": \"Glabron\", \"year\": 1932, \"site\": \"University Farm\"},\r\n]\r\n\r\n\r\nTo facilitate visualization, it may be useful to nest the elements first by year, and then by variety, as follows:\r\n\r\n>>> from nesting import Nest\r\n>>> (Nest()\r\n... .key( lambda d: d['year'] )\r\n... .key( lambda d: d['variety'] )\r\n... .entries(yields))\r\n\r\n\r\nOr more concisely:\r\n\r\n>>> (Nest()\r\n... .key('year')\r\n... .key('variety')\r\n... .entries(yields))\r\n\r\n\r\n...as both the `key` and `prop` functions will interpret non-callables as they key to look up.\r\n\r\nThis returns a nested array. Each element of the outer array is a key-values pair, listing the values for each distinct key::\r\n\r\n [ {\"key\": 1931, \"values\": [\r\n {\"key\": \"Manchuria\", \"values\": [\r\n {\"yield\": 27.00, \"variety\": \"Manchuria\", \"year\": 1931, \"site\": \"University Farm\"},\r\n {\"yield\": 48.87, \"variety\": \"Manchuria\", \"year\": 1931, \"site\": \"Waseca\"},\r\n {\"yield\": 27.43, \"variety\": \"Manchuria\", \"year\": 1931, \"site\": \"Morris\"}, ]},\r\n {\"key\": \"Glabron\", \"values\": [\r\n {\"yield\": 43.07, \"variety\": \"Glabron\", \"year\": 1931, \"site\": \"University Farm\"},\r\n {\"yield\": 55.20, \"variety\": \"Glabron\", \"year\": 1931, \"site\": \"Waseca\"}, ]}, \r\n ]},\r\n {\"key\": 1932, \"values\": [\r\n {\"key\": \"Glabron\", \"values\": [\r\n {\"yield\": 16.18, \"variety\": \"Glabron\", \"year\": 1932, \"site\": \"University Farm\"}, ]},\r\n ]},\r\n ]\r\n\r\n\r\nThe nested form allows easy iteration and generation of hierarchical structures in SVG or HTML.\r\n\r\n--\r\n\r\nThis port is open-source, freely licensed under the `MIT License `__.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dsc/nesting", "keywords": "nesting operator data series", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "nesting", "package_url": "https://pypi.org/project/nesting/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/nesting/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/dsc/nesting" }, "release_url": "https://pypi.org/project/nesting/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Operator to construct nested rollups from lists of records.", "version": "0.1.0" }, "last_serial": 795309, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7bbab2843f46eddbd593c8d695c30e50", "sha256": "40805454c2b76e65f64e969999615356c48a3ec68169038ca95efd577d3f82f7" }, "downloads": -1, "filename": "nesting-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7bbab2843f46eddbd593c8d695c30e50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4805, "upload_time": "2012-07-19T17:33:52", "url": "https://files.pythonhosted.org/packages/1f/bf/5b5a84dc8b093c7ae7eb313ff2b7d012405f6266742866b00594601e51c2/nesting-0.1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "c11c293f502a97298aa1b3fac4687ba7", "sha256": "f31b7dd8a3ed6050ceffa686777eb1940a18e2348cfda6e93aa583355b5316b7" }, "downloads": -1, "filename": "nesting-0.1.0.zip", "has_sig": false, "md5_digest": "c11c293f502a97298aa1b3fac4687ba7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10636, "upload_time": "2012-07-19T17:33:50", "url": "https://files.pythonhosted.org/packages/f0/57/126c1c8b068d96e9cdc74d87295ae72bb56ce15dd8f8602308bb07257f56/nesting-0.1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7bbab2843f46eddbd593c8d695c30e50", "sha256": "40805454c2b76e65f64e969999615356c48a3ec68169038ca95efd577d3f82f7" }, "downloads": -1, "filename": "nesting-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7bbab2843f46eddbd593c8d695c30e50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4805, "upload_time": "2012-07-19T17:33:52", "url": "https://files.pythonhosted.org/packages/1f/bf/5b5a84dc8b093c7ae7eb313ff2b7d012405f6266742866b00594601e51c2/nesting-0.1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "c11c293f502a97298aa1b3fac4687ba7", "sha256": "f31b7dd8a3ed6050ceffa686777eb1940a18e2348cfda6e93aa583355b5316b7" }, "downloads": -1, "filename": "nesting-0.1.0.zip", "has_sig": false, "md5_digest": "c11c293f502a97298aa1b3fac4687ba7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10636, "upload_time": "2012-07-19T17:33:50", "url": "https://files.pythonhosted.org/packages/f0/57/126c1c8b068d96e9cdc74d87295ae72bb56ce15dd8f8602308bb07257f56/nesting-0.1.0.zip" } ] }