{"id":17277628,"url":"https://github.com/sjtechdev/fastgrouper","last_synced_at":"2026-05-10T15:37:56.080Z","repository":{"id":42032412,"uuid":"482059639","full_name":"sjtechdev/fastgrouper","owner":"sjtechdev","description":"Fast groupby-apply operations in python.","archived":false,"fork":false,"pushed_at":"2023-01-14T16:21:27.000Z","size":33,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-17T06:17:20.739Z","etag":null,"topics":["computational","groupby","groupby-apply","groupby-function","groupby-method","groupby-transformation","groupbykey","grouping","grouping-operations","numpy","pandas","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sjtechdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-15T19:09:51.000Z","updated_at":"2024-04-27T07:54:44.000Z","dependencies_parsed_at":"2023-02-09T20:01:00.454Z","dependency_job_id":null,"html_url":"https://github.com/sjtechdev/fastgrouper","commit_stats":null,"previous_names":["sjoshistrats/fastgrouper"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sjtechdev/fastgrouper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjtechdev%2Ffastgrouper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjtechdev%2Ffastgrouper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjtechdev%2Ffastgrouper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjtechdev%2Ffastgrouper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjtechdev","download_url":"https://codeload.github.com/sjtechdev/fastgrouper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjtechdev%2Ffastgrouper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267569551,"owners_count":24109099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational","groupby","groupby-apply","groupby-function","groupby-method","groupby-transformation","groupbykey","grouping","grouping-operations","numpy","pandas","python","python3"],"created_at":"2024-10-15T09:09:32.752Z","updated_at":"2026-04-10T23:39:57.791Z","avatar_url":"https://github.com/sjtechdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastgrouper\nFast groupby-apply operations in python.\n  \n# Install\n  \nUsers can install the package from PyPI via:\n  \n```shell\npython -m pip install fastgrouper\n```\n\n# Usage\n\nUse the `arr` interface, for numpy array related applications.\n\n```python\nimport numpy as np\nimport fastgrouper.arr\n  \ndef baz(x, y):\n    return np.mean(x + y) - 3\n\n# Sample arrays, to slice\nxvals = np.array([1, 2, 10])\nyvals = np.array([4, 5, 6])\n  \n# Group ids\ngids  = np.array([1, -3, 1])\n\n# Perform groupby-apply; note that keyword args are supported as well.\ngrpd = fastgrouper.arr.Grouped(gids)\nresult = grpd.apply(baz, xvals, y=yvals) # np.array([7.5, 4])\n\n# The gids correponding to the result above can be found via the `dedup_gids` attribute.\ngrpd.dedup_gids # np.array([ 1, -3])\n\n# Users can also perform groupby-apply, and then expand results back to align with the original gids.\nresult = grpd.apply_expand(baz, xvals, yvals) # np.array([7.5, 4, 7.5])\n```\n\nThe `li` interface returns the results over the groups as a list (instead of an array); this may be useful for functions that return different-sized results. Note that in all interfaces (e.g. both `arr` and `li`), the order of the group elements is preserved when the group slices are passed to the function being applied.\n\n  \n```python\nimport numpy as np\nimport fastgrouper.li\n  \ndef bop(x):\n    return list(x)\n\n# Sample arrays, to slice\nxvals = np.array([2, 3, 4])\n  \n# Group ids\ngids  = np.array([10, -20, 10])\n\ngrpd = fastgrouper.li.Grouped(gids)\ngrpd.apply(bop, xvals) # [[2, 4], [3]]\n```\n  \nFor additional examples, checkout the [tests](./python/fastgrouper/test).\n  \n# Benchmarks\n\nCheckout the benchmarks [here](./python/fastgrouper/test/test_grouped_benchmark.py) for a sample comparison between the `pandas` groupby-apply and `fastgrouper` groupby-apply workflows. While it is difficult to compare the two perfectly, I tried to make the comparison as fair as possible.\n\nResults from running the benchmarks on a sample machine with an Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz:\n  \n```console\n---------------------------------------------------------------------------------------------- benchmark: 4 tests ---------------------------------------------------------------------------------------------\nName (time in ms)                                  Min                Max               Mean            StdDev             Median               IQR            Outliers       OPS            Rounds  Iterations\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_fastgrouper_arr_slice_apply_benchmark      5.8296 (1.0)       6.6786 (1.0)       6.0080 (1.0)      0.1165 (1.0)       6.0071 (1.0)      0.1294 (1.0)          35;5  166.4435 (1.0)         147           1\ntest_fastgrouper_all_steps_benchmark            7.7704 (1.33)     10.3270 (1.55)      8.0946 (1.35)     0.3171 (2.72)      8.0872 (1.35)     0.2511 (1.94)          6;2  123.5386 (0.74)        121           1\ntest_pure_pandas_slice_apply_benchmark         42.4697 (7.29)     46.9096 (7.02)     43.0534 (7.17)     0.9816 (8.42)     42.6915 (7.11)     0.4361 (3.37)          2;3   23.2270 (0.14)         22           1\ntest_pure_pandas_all_steps_benchmark           43.4275 (7.45)     45.2340 (6.77)     43.8837 (7.30)     0.4243 (3.64)     43.7748 (7.29)     0.4973 (3.84)          3;1   22.7875 (0.14)         23           1\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjtechdev%2Ffastgrouper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjtechdev%2Ffastgrouper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjtechdev%2Ffastgrouper/lists"}