{ "info": { "author": "Guillaume Calmettes", "author_email": "gcalmettes@g.ucla.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# `gcGroupbyExtension`: chain `.apply` methods on Pandas groupby object\n\n## Install\nThe extension is available on [PyPi](https://pypi.org/project/gcGroupbyExtension-gcalmettes/)\n```\npip install gcGroupbyExtension-gcalmettes\n```\n\n(Or if you do not want to install the package in your python distribution, just download this repo and place the `gcGroupbyExtension` folder in the folder you're running your python script/notebook in.)\n\n## Import\nOnce installed, the extension can be imported via:\n```\nimport gcGroupbyExtension\n```\n\n## What problems does this extension try to solve?\n[Pandas](https://pandas.pydata.org) provides both the [`.pipe`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.pipe.html) and [`.apply`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.apply.html) methods to work on its [groupby](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html) object.\nThe main difference between `.pipe` and `.apply` in the groupby context is that you have access to the entire scope of the groupby object (each group) with `.pipe`, while you only have access to the subcomponents scope (in the context of a groupby the subcomponents are slices of the dataframe that called groupby where each slice is a dataframe itself. This is analogous for a series groupby.)\n1) The `.pipe` method can be chained, while the `.apply` method can't.\n2) You can use the [`.agg`](https://pandas.pydata.org/pandas-docs/version/0.22/generated/pandas.core.groupby.DataFrameGroupBy.agg.html) method to limit the application of the functions on particular columns of the groups, but it is cumbersome to apply specific functions independantly on only a selection of the groups.\n3) There is no easy way to construct independant pipelines of functions for each group.\n\nThis extension provides this capability.\n\n## What does this extension actually do?\nThis extension allows to construct a pipeline of functions to be applied independently on the groups of a groupby object. The functions/transformations to be applied can be the same for all the groups or scoped to (a) specific group(s).\n\n**Details:**\nThis library registers a [custom accessor](https://pandas.pydata.org/pandas-docs/stable/development/extending.html) on pandas DataFrame and Series objects.\nThe methods of this extension are registered under the `gc` namespace.\n\nSee the [DEMO notebook](https://github.com/gcalmettes/pandas-groupby-apply-chaining-extension/blob/master/demo.ipynb) for details. \n\n## Care to show the syntax?\nSure! See the [DEMO notebook](https://github.com/gcalmettes/pandas-groupby-apply-chaining-extension/blob/master/demo.ipynb) for more details, but basically, you can do things like this:\n\n```\n(df.gc.groupby(\"nameOfColumn\")\n .resetIndex() # this is a special method baked in\n .apply(lambda x: x * 5, lambda x: x + x.iloc[3]) # accepts multiple functions\n .apply(mySpecialFunction, onlyGroups=['group1']) # limit the function to specific group(s)\n .apply(lambda x: x - x.mean(), ignoreGroups=['group4', 'group6']) # limit the function to specific group(s)\n .apply(lambda x: x.std(axis=1))\n .concat(axis=0, multiIndex=None).plot()\n)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gcalmettes/pandas-groupby-apply-chaining-extension", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "gcGroupbyExtension-gcalmettes", "package_url": "https://pypi.org/project/gcGroupbyExtension-gcalmettes/", "platform": "", "project_url": "https://pypi.org/project/gcGroupbyExtension-gcalmettes/", "project_urls": { "Homepage": "https://github.com/gcalmettes/pandas-groupby-apply-chaining-extension" }, "release_url": "https://pypi.org/project/gcGroupbyExtension-gcalmettes/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Allows to construct a pipeline of functions to be applied independently on the groups of a groupby object.", "version": "0.0.3" }, "last_serial": 5142131, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "732053f3b1072d556062752a3c618dab", "sha256": "8f17b3abbec3e889ebe53309484ca596800447a79b4814cf2134fbf2978e59d0" }, "downloads": -1, "filename": "gcGroupbyExtension_gcalmettes-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "732053f3b1072d556062752a3c618dab", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6130, "upload_time": "2019-04-14T21:49:55", "url": "https://files.pythonhosted.org/packages/a3/01/83396f754f3e106248002ae99552f61d822d2286474676020ac86f6ffb79/gcGroupbyExtension_gcalmettes-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b6d4027071bc1e21e2c29055aa8636f8", "sha256": "3a78db84b07d64887c076773bf4bdda88052f84fcc05ce8b3769c1712af11528" }, "downloads": -1, "filename": "gcGroupbyExtension-gcalmettes-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b6d4027071bc1e21e2c29055aa8636f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4785, "upload_time": "2019-04-14T21:49:57", "url": "https://files.pythonhosted.org/packages/a7/18/2455741285e32923694eb3440d1da0dfa7b7fe23128920ea09ad1c502f1e/gcGroupbyExtension-gcalmettes-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "284988bf7faf3462840aa620db97a1a1", "sha256": "5661a5039893572778aeedd82511e231ebbc11a51271028987266c1d95a2d27b" }, "downloads": -1, "filename": "gcGroupbyExtension-gcalmettes-0.0.2.tar.gz", "has_sig": false, "md5_digest": "284988bf7faf3462840aa620db97a1a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5010, "upload_time": "2019-04-14T22:06:58", "url": "https://files.pythonhosted.org/packages/4f/14/b35eafd72935301012bbcd41607fdbbd7f5379e813a1e391707bf4ba3578/gcGroupbyExtension-gcalmettes-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "d6b93204ebaed8195f6cccbfa06a0521", "sha256": "f2791fa8acb118bfd3cb0df10369780d630a09b4d62144e83ff3b0ade19ec19f" }, "downloads": -1, "filename": "gcGroupbyExtension_gcalmettes-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d6b93204ebaed8195f6cccbfa06a0521", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6324, "upload_time": "2019-04-14T22:14:01", "url": "https://files.pythonhosted.org/packages/44/8f/3bcb3da012970fe7495a188cc29543c88f232e0f91642681b17e016ba9b4/gcGroupbyExtension_gcalmettes-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b9767aea16c49d400676801373ebccf7", "sha256": "3fa55ea4dd1715859e4d8f1ce65dec856e205e6ed0f5c7d908a677a7c34bfd2a" }, "downloads": -1, "filename": "gcGroupbyExtension-gcalmettes-0.0.3.tar.gz", "has_sig": false, "md5_digest": "b9767aea16c49d400676801373ebccf7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5009, "upload_time": "2019-04-14T22:14:02", "url": "https://files.pythonhosted.org/packages/cf/e3/f14b24c4fdf727521fae4b9e2cfd53640f713643bee3d871793bcf74523b/gcGroupbyExtension-gcalmettes-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d6b93204ebaed8195f6cccbfa06a0521", "sha256": "f2791fa8acb118bfd3cb0df10369780d630a09b4d62144e83ff3b0ade19ec19f" }, "downloads": -1, "filename": "gcGroupbyExtension_gcalmettes-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d6b93204ebaed8195f6cccbfa06a0521", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6324, "upload_time": "2019-04-14T22:14:01", "url": "https://files.pythonhosted.org/packages/44/8f/3bcb3da012970fe7495a188cc29543c88f232e0f91642681b17e016ba9b4/gcGroupbyExtension_gcalmettes-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b9767aea16c49d400676801373ebccf7", "sha256": "3fa55ea4dd1715859e4d8f1ce65dec856e205e6ed0f5c7d908a677a7c34bfd2a" }, "downloads": -1, "filename": "gcGroupbyExtension-gcalmettes-0.0.3.tar.gz", "has_sig": false, "md5_digest": "b9767aea16c49d400676801373ebccf7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5009, "upload_time": "2019-04-14T22:14:02", "url": "https://files.pythonhosted.org/packages/cf/e3/f14b24c4fdf727521fae4b9e2cfd53640f713643bee3d871793bcf74523b/gcGroupbyExtension-gcalmettes-0.0.3.tar.gz" } ] }