{"id":26927576,"url":"https://github.com/lmmx/polars-permute-plugin","last_synced_at":"2025-04-02T04:16:59.456Z","repository":{"id":276117386,"uuid":"928289594","full_name":"lmmx/polars-permute-plugin","owner":"lmmx","description":"A Polars plugin for easily reordering DataFrame columns","archived":false,"fork":false,"pushed_at":"2025-03-24T22:04:11.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T23:19:38.131Z","etag":null,"topics":["polars","polars-plugins","reordering"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/polars-permute/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lmmx.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-06T11:44:18.000Z","updated_at":"2025-03-24T22:04:14.000Z","dependencies_parsed_at":"2025-03-24T23:19:23.447Z","dependency_job_id":"f138895d-4768-4525-9c7c-34d4cb9db0a0","html_url":"https://github.com/lmmx/polars-permute-plugin","commit_stats":null,"previous_names":["lmmx/polars-permute-plugin"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmmx%2Fpolars-permute-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmmx%2Fpolars-permute-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmmx%2Fpolars-permute-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmmx%2Fpolars-permute-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lmmx","download_url":"https://codeload.github.com/lmmx/polars-permute-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246752628,"owners_count":20827987,"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","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":["polars","polars-plugins","reordering"],"created_at":"2025-04-02T04:16:58.942Z","updated_at":"2025-04-02T04:16:59.438Z","avatar_url":"https://github.com/lmmx.png","language":"Python","funding_links":[],"categories":["Libraries/Packages/Scripts"],"sub_categories":["Polars plugins"],"readme":"# Polars Permute Plugin\n\nA Polars plugin for easily reordering DataFrame columns.\n\nSupports column permutations like prepending, appending, shifting, and swapping.\n\n## Installation\n\n```python\npip install polars-permute[polars]\n```\n\nOn older CPUs run:\n\n```python\npip install polars-permute[polars-lts-cpu]\n```\n\n## Features\n\n- Supports both string column names and Polars expressions\n- Handles single or multiple columns\n- Maintains relative ordering of moved columns\n- Chain operations together\n- Gracefully handles edge cases (non-existent columns, empty inputs)\n\n## Usage\n\nThe plugin adds a `permute` namespace to Polars DataFrames with methods for column reordering:\n\n```python\nimport polars as pl\nimport polars_permute\n\n# Create a sample DataFrame\ndf = pl.DataFrame({\n    \"a\": [1, 2, 3],\n    \"b\": [4, 5, 6],\n    \"c\": [7, 8, 9],\n    \"d\": [10, 11, 12]\n})\n\n# Move column 'd' to the start\ndf.permute.prepend(\"d\")\n\n# Move multiple columns to the end\ndf.permute.append([\"a\", \"b\"])\n\n# Move columns to a specific position\ndf.permute.at([\"b\", \"c\"], index=0)\n\n# Shift columns left/right\ndf.permute.shift(\"a\", \"b\", steps=1, direction=\"right\")\n\n# Swap two columns\ndf.permute.swap(\"a\", \"d\")\n```\n\n## API Reference\n\n### prepend(cols)\nMove specified column(s) to the start (index 0).\n```python\ndf.permute.prepend(\"d\")  # Single column\ndf.permute.prepend([\"c\", \"d\"])  # Multiple columns\ndf.permute.prepend(pl.col(\"a\").alias(\"x\"))  # Using expressions\n```\n\n### append(cols)\nMove specified column(s) to the end.\n```python\ndf.permute.append(\"a\")\ndf.permute.append([\"a\", \"b\"])\n```\n\n### at(cols, index)\nMove specified column(s) to exact position.\n```python\ndf.permute.at(\"d\", 1)  # Move 'd' to index 1\ndf.permute.at([\"b\", \"c\"], 0)  # Move multiple columns\n```\n\n### shift(cols, steps=1, direction=\"left\")\nShift column(s) left or right by steps.\n```python\ndf.permute.shift(\"c\", steps=1, direction=\"left\")\ndf.permute.shift(\"a\", \"b\", steps=2, direction=\"right\")\n```\n\n### swap(col1, col2)\nSwap positions of two columns.\n```python\ndf.permute.swap(\"a\", \"d\")\n```\n\n## Notes\n\n- Operations create a new DataFrame; the original is not modified\n- Column order is preserved for multiple column operations\n- Invalid columns are ignored gracefully\n- Out-of-bounds indexes are clamped to valid range\n\n## Contributing\n\nFeel free to open issues or submit pull requests for improvements or bug fixes.\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmmx%2Fpolars-permute-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flmmx%2Fpolars-permute-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmmx%2Fpolars-permute-plugin/lists"}