{"id":17477721,"url":"https://github.com/fbraza/python-tocase","last_synced_at":"2025-10-27T20:33:12.047Z","repository":{"id":57476052,"uuid":"387184704","full_name":"fbraza/python-tocase","owner":"fbraza","description":"A library to help recasing your strings","archived":false,"fork":false,"pushed_at":"2021-11-12T18:43:39.000Z","size":496,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T08:13:08.577Z","etag":null,"topics":["case-converter","data-cleaning","pandas","python","python3","strings-manipulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fbraza.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-18T13:39:05.000Z","updated_at":"2023-09-09T17:22:01.000Z","dependencies_parsed_at":"2022-09-07T17:13:12.756Z","dependency_job_id":null,"html_url":"https://github.com/fbraza/python-tocase","commit_stats":null,"previous_names":["fbraza/tocase"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbraza%2Fpython-tocase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbraza%2Fpython-tocase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbraza%2Fpython-tocase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbraza%2Fpython-tocase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fbraza","download_url":"https://codeload.github.com/fbraza/python-tocase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248190801,"owners_count":21062345,"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":["case-converter","data-cleaning","pandas","python","python3","strings-manipulation"],"created_at":"2024-10-18T20:09:10.780Z","updated_at":"2025-10-27T20:33:07.020Z","avatar_url":"https://github.com/fbraza.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToCase\n![](assets/tocase.png)\n\n[![PyPI Version][pypi-image]][pypi-url]\n[![Build Status][build-image]][build-url]\n\n\u003c!-- Badges --\u003e\n\n[pypi-image]: https://img.shields.io/pypi/v/tocase\n[pypi-url]: https://pypi.org/project/tocase/\n[build-image]: https://github.com/fbraza/tocase/actions/workflows/ci.yml/badge.svg\n[build-url]: https://github.com/fbraza/tocase/blob/master/.github/workflows/ci.yml\n\n## Functionality\n\n`tocase` leverages the `regex` library to convert your strings into any case.\n\n## Setup\n\nTo install the package run the following command:\n\n```bash\npip install tocase\n```\n\nOnce installed, import the `for_strings` if you want to use the basic API to recase strings. Import the `for_pandas` modules to use the pandas API to recase column names and column values.\n\n```python\nfrom tocase.for_strings import ToCase # if you want to use the string API only\nimport tocase.for_pandas # if you want to recase strings in Pandas DataFrames\n```\n\n## Usage\n\n### Camel\n\nIt is a naming convention where the first letter in compound words is capitalized, except for the first one.\n\n```python\n# Example with simple string\nTocase(\"camel-case\").camel() # ==\u003e camelCase\nTocase(\"camel case\").camel() # ==\u003e camelCase\n```\n\n### Constant\n\nIt is a naming convention where all letters in compound words are capitalized. Words are joined with an underscore.\n\n```python\n# Example with simple string\nTocase(\"Constant-case\").constant() # ==\u003e CONSTANT_CASE\nTocase(\"constant Case\").constant() # ==\u003e CONSTANT_CASE\n```\n\n### Dot\n\nIt is a naming convention where all letters in compound words are lowercased. Words are joined with a dot.\n\n```python\n# Example with simple string\nTocase(\"Dot-case\").dot() # ==\u003e dot.case\nTocase(\"dot Case\").dot() # ==\u003e dot.case\n```\n\n### Header\n\nIt is a naming convention where the first letter in compound words is capitalized. Words are joined by a dash.\n\n```python\n# Example with simple string\nTocase(\"Header-case\").header() # ==\u003e Header-Case\nTocase(\"header Case\").header() # ==\u003e Header-Case\n```\n\n### Kebab\n\nIt is a naming convention where all letters in compound words are lowercased. Words are joined by a dash.\n\n```python\n# Example with simple string\nTocase(\"Kebab-case\").kebab() # ==\u003e kebab-case\nTocase(\"kebab Case\").kebab() # ==\u003e kebab-case\n```\n\n### Pascal\n\nIt is a naming convention where the first letter in compound words is capitalized.\n\n```python\n# Example with simple string\nTocase(\"Pascal-case\").pascal() # ==\u003e PascalCase\nTocase(\"pascal Case\").pascal() # ==\u003e PascalCase\n```\n\n### Snake\n\nIt is a naming convention where all letters in compound words are lowercased. Words are joined by an underscore.\n\n```python\n# Example with simple string\nTocase(\"Snake-case\").snake() # ==\u003e snake_case\nTocase(\"snake Case\").snake() # ==\u003e snake_case\n```\n\n### Title\n\nIt is a naming convention where the first letter in compound words is capitalized. Words are separated by a space.\n\n```python\n# Example with simple string\nTocase(\"Title-case\").title() # ==\u003e \"Title Case\"\nTocase(\"title Case\").title() # ==\u003e \"Title Case\"\n```\n\n### With pandas DataFrames\n\nYou can work with pandas DataFrame to recase columns names or column values. See the following examples with fake data.\n\n```python\ncolumns = [\"first name\", \"last name\", \"age\", \"family doctor\"]\nvalues = [\n        [\"Jules\", \"Otti\", 35, \"Dr James Porter\"],\n        [\"Marie\", \"Curie\", 22, \"Dr Vicky Laporte\"],\n        [\"Marc\", \"El Bichon\", 35, \"Dr Hyde Frank\"]\n        ]\ndata =  pd.DataFrame(data=values, columns=columns)\n```\n\nTo recase columns names, use the `col` DataFrame accessor and the appropriate recasing function described above.\n\n```python\nprint(data)\n\n\"\"\"\n  first name last name  age   family doctor\n0      Jules      Otti   35   DrJamesPorter\n1      Marie     Curie   22  DrVickyLaporte\n2       Marc  ElBichon   35     DrHydeFrank\n\n\"\"\"\n\nprint(data.col.constant())\n\n\"\"\"\n  FIRST_NAME LAST_NAME  AGE   FAMILY_DOCTOR\n0      Jules      Otti   35   DrJamesPorter\n1      Marie     Curie   22  DrVickyLaporte\n2       Marc  ElBichon   35     DrHydeFrank\n\"\"\"\n```\n\nTo recase columns values, use the `val` DataFrame accessor, the appropriate recasing function described above with a list of the columns to be processed.\n\n```python\ncolumns_to_process = [\"first name\", \"last name\", \"family doctor\"]\nprint(data.val.constant(columns_to_process))\n\n\"\"\"\n  first name  last name  age     family doctor\n0      JULES       OTTI   35   DR_JAMES_PORTER\n1      MARIE      CURIE   22  DR_VICKY_LAPORTE\n2       MARC  EL_BICHON   35     DR_HYDE_FRANK\n\n\"\"\"\n```\n\n## For developers\n\nClone or download the repository on your machine. If you have `poetry` installed just run the following command to restore the working environment:\n\n```bash\npoetry install\n```\n\nIf you don't have `poetry` you can use `pip` and the `requirements.txt` file:\n\n```bash\npip install -r requirements.txt\n```\n\nTo run tests, stay at the root of the directory and run:\n\n```bash\npytest -v\n```\n\nAll contributions are more than welcome. So feel free to to make a PR.\n\n## Author\n\nFaouzi Braza\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbraza%2Fpython-tocase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffbraza%2Fpython-tocase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbraza%2Fpython-tocase/lists"}