Column Names#

class polars_extensions.name.NameExtensionNameSpace(df: DataFrame)[source]#

Bases: object

Functions that extend the Name capabilities of polars DataFrames

Methods

to_camel_case()

Converts column names to camelCase

to_kebeb_case()

Converts column names to kebab-case

to_pascal_case()

Converts column names to PascalCase

to_pascal_snake_case()

Converts column names to Pascal_Snake_Case

to_snake_case()

Converts column names to snake_case

to_train_case()

Converts column names to Train-Case

to_upper_snake_case()

Converts column names to UPPER_SNAKE_CASE

to_camel_case() DataFrame[source]#

Converts column names to camelCase

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_camel_case()
shape: (5, 8)
┌────────────┬───────────┬──────────┬─────────────┬─────────────┬────────────┬────────────┬────────┐
│ employeeId ┆ firstName ┆ lastName ┆ email       ┆ jobTitle    ┆ dateOfBirt ┆ dateOfHire ┆ salary │
│ ---        ┆ ---       ┆ ---      ┆ ---         ┆ ---         ┆ h          ┆ ---        ┆ ---    │
│ i64        ┆ str       ┆ str      ┆ str         ┆ str         ┆ ---        ┆ str        ┆ i64    │
│            ┆           ┆          ┆             ┆             ┆ str        ┆            ┆        │
╞════════════╪═══════════╪══════════╪═════════════╪═════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john      ┆ doe      ┆ john.doe@ex ┆ software_en ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆           ┆          ┆ ample.com   ┆ gineer      ┆            ┆            ┆        │
│ 2          ┆ jane      ┆ smith    ┆ jane.smith@ ┆ data_scient ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆           ┆          ┆ example.com ┆ ist         ┆            ┆            ┆        │
│ 3          ┆ bob       ┆ johnson  ┆ bob.johnson ┆ product_man ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆           ┆          ┆ @example.co ┆ ager        ┆            ┆            ┆        │
│            ┆           ┆          ┆ m           ┆             ┆            ┆            ┆        │
│ 4          ┆ alice     ┆ davis    ┆ alice.davis ┆ ux_designer ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆           ┆          ┆ @example.co ┆             ┆            ┆            ┆        │
│            ┆           ┆          ┆ m           ┆             ┆            ┆            ┆        │
│ 5          ┆ charlie   ┆ brown    ┆ charlie.bro ┆ qa_engineer ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆           ┆          ┆ wn@example. ┆             ┆            ┆            ┆        │
│            ┆           ┆          ┆ com         ┆             ┆            ┆            ┆        │
└────────────┴───────────┴──────────┴─────────────┴─────────────┴────────────┴────────────┴────────┘
to_kebeb_case() DataFrame[source]#

Converts column names to kebab-case

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_kebeb_case()
shape: (5, 8)
┌────────────┬────────────┬───────────┬────────────┬────────────┬────────────┬────────────┬────────┐
│ employee-i ┆ first-name ┆ last-name ┆ email      ┆ job-title  ┆ date-of-bi ┆ date-of-hi ┆ salary │
│ d          ┆ ---        ┆ ---       ┆ ---        ┆ ---        ┆ rth        ┆ re         ┆ ---    │
│ ---        ┆ str        ┆ str       ┆ str        ┆ str        ┆ ---        ┆ ---        ┆ i64    │
│ i64        ┆            ┆           ┆            ┆            ┆ str        ┆ str        ┆        │
╞════════════╪════════════╪═══════════╪════════════╪════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john       ┆ doe       ┆ john.doe@e ┆ software_e ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆            ┆           ┆ xample.com ┆ ngineer    ┆            ┆            ┆        │
│ 2          ┆ jane       ┆ smith     ┆ jane.smith ┆ data_scien ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆            ┆           ┆ @example.c ┆ tist       ┆            ┆            ┆        │
│            ┆            ┆           ┆ om         ┆            ┆            ┆            ┆        │
│ 3          ┆ bob        ┆ johnson   ┆ bob.johnso ┆ product_ma ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆            ┆           ┆ n@example. ┆ nager      ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 4          ┆ alice      ┆ davis     ┆ alice.davi ┆ ux_designe ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆            ┆           ┆ s@example. ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 5          ┆ charlie    ┆ brown     ┆ charlie.br ┆ qa_enginee ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆            ┆           ┆ own@exampl ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ e.com      ┆            ┆            ┆            ┆        │
└────────────┴────────────┴───────────┴────────────┴────────────┴────────────┴────────────┴────────┘
to_pascal_case() DataFrame[source]#

Converts column names to PascalCase

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_pascal_case()
shape: (5, 8)
┌────────────┬───────────┬──────────┬─────────────┬─────────────┬────────────┬────────────┬────────┐
│ EmployeeId ┆ FirstName ┆ LastName ┆ Email       ┆ JobTitle    ┆ DateOfBirt ┆ DateOfHire ┆ Salary │
│ ---        ┆ ---       ┆ ---      ┆ ---         ┆ ---         ┆ h          ┆ ---        ┆ ---    │
│ i64        ┆ str       ┆ str      ┆ str         ┆ str         ┆ ---        ┆ str        ┆ i64    │
│            ┆           ┆          ┆             ┆             ┆ str        ┆            ┆        │
╞════════════╪═══════════╪══════════╪═════════════╪═════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john      ┆ doe      ┆ john.doe@ex ┆ software_en ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆           ┆          ┆ ample.com   ┆ gineer      ┆            ┆            ┆        │
│ 2          ┆ jane      ┆ smith    ┆ jane.smith@ ┆ data_scient ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆           ┆          ┆ example.com ┆ ist         ┆            ┆            ┆        │
│ 3          ┆ bob       ┆ johnson  ┆ bob.johnson ┆ product_man ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆           ┆          ┆ @example.co ┆ ager        ┆            ┆            ┆        │
│            ┆           ┆          ┆ m           ┆             ┆            ┆            ┆        │
│ 4          ┆ alice     ┆ davis    ┆ alice.davis ┆ ux_designer ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆           ┆          ┆ @example.co ┆             ┆            ┆            ┆        │
│            ┆           ┆          ┆ m           ┆             ┆            ┆            ┆        │
│ 5          ┆ charlie   ┆ brown    ┆ charlie.bro ┆ qa_engineer ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆           ┆          ┆ wn@example. ┆             ┆            ┆            ┆        │
│            ┆           ┆          ┆ com         ┆             ┆            ┆            ┆        │
└────────────┴───────────┴──────────┴─────────────┴─────────────┴────────────┴────────────┴────────┘
to_pascal_snake_case() DataFrame[source]#

Converts column names to Pascal_Snake_Case

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_pascal_snake_case()
shape: (5, 8)
┌────────────┬────────────┬───────────┬────────────┬────────────┬────────────┬────────────┬────────┐
│ Employee_I ┆ First_Name ┆ Last_Name ┆ Email      ┆ Job_Title  ┆ Date_Of_Bi ┆ Date_Of_Hi ┆ Salary │
│ d          ┆ ---        ┆ ---       ┆ ---        ┆ ---        ┆ rth        ┆ re         ┆ ---    │
│ ---        ┆ str        ┆ str       ┆ str        ┆ str        ┆ ---        ┆ ---        ┆ i64    │
│ i64        ┆            ┆           ┆            ┆            ┆ str        ┆ str        ┆        │
╞════════════╪════════════╪═══════════╪════════════╪════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john       ┆ doe       ┆ john.doe@e ┆ software_e ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆            ┆           ┆ xample.com ┆ ngineer    ┆            ┆            ┆        │
│ 2          ┆ jane       ┆ smith     ┆ jane.smith ┆ data_scien ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆            ┆           ┆ @example.c ┆ tist       ┆            ┆            ┆        │
│            ┆            ┆           ┆ om         ┆            ┆            ┆            ┆        │
│ 3          ┆ bob        ┆ johnson   ┆ bob.johnso ┆ product_ma ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆            ┆           ┆ n@example. ┆ nager      ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 4          ┆ alice      ┆ davis     ┆ alice.davi ┆ ux_designe ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆            ┆           ┆ s@example. ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 5          ┆ charlie    ┆ brown     ┆ charlie.br ┆ qa_enginee ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆            ┆           ┆ own@exampl ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ e.com      ┆            ┆            ┆            ┆        │
└────────────┴────────────┴───────────┴────────────┴────────────┴────────────┴────────────┴────────┘
to_snake_case() DataFrame[source]#

Converts column names to snake_case

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_snake_case()
shape: (5, 8)
┌────────────┬────────────┬───────────┬────────────┬────────────┬────────────┬────────────┬────────┐
│ employee_i ┆ first_name ┆ last_name ┆ email      ┆ job_title  ┆ date_of_bi ┆ date_of_hi ┆ salary │
│ d          ┆ ---        ┆ ---       ┆ ---        ┆ ---        ┆ rth        ┆ re         ┆ ---    │
│ ---        ┆ str        ┆ str       ┆ str        ┆ str        ┆ ---        ┆ ---        ┆ i64    │
│ i64        ┆            ┆           ┆            ┆            ┆ str        ┆ str        ┆        │
╞════════════╪════════════╪═══════════╪════════════╪════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john       ┆ doe       ┆ john.doe@e ┆ software_e ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆            ┆           ┆ xample.com ┆ ngineer    ┆            ┆            ┆        │
│ 2          ┆ jane       ┆ smith     ┆ jane.smith ┆ data_scien ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆            ┆           ┆ @example.c ┆ tist       ┆            ┆            ┆        │
│            ┆            ┆           ┆ om         ┆            ┆            ┆            ┆        │
│ 3          ┆ bob        ┆ johnson   ┆ bob.johnso ┆ product_ma ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆            ┆           ┆ n@example. ┆ nager      ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 4          ┆ alice      ┆ davis     ┆ alice.davi ┆ ux_designe ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆            ┆           ┆ s@example. ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 5          ┆ charlie    ┆ brown     ┆ charlie.br ┆ qa_enginee ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆            ┆           ┆ own@exampl ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ e.com      ┆            ┆            ┆            ┆        │
└────────────┴────────────┴───────────┴────────────┴────────────┴────────────┴────────────┴────────┘
to_train_case() DataFrame[source]#

Converts column names to Train-Case

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_train_case()
shape: (5, 8)
┌────────────┬────────────┬───────────┬────────────┬────────────┬────────────┬────────────┬────────┐
│ Employee-I ┆ First-Name ┆ Last-Name ┆ Email      ┆ Job-Title  ┆ Date-Of-Bi ┆ Date-Of-Hi ┆ Salary │
│ d          ┆ ---        ┆ ---       ┆ ---        ┆ ---        ┆ rth        ┆ re         ┆ ---    │
│ ---        ┆ str        ┆ str       ┆ str        ┆ str        ┆ ---        ┆ ---        ┆ i64    │
│ i64        ┆            ┆           ┆            ┆            ┆ str        ┆ str        ┆        │
╞════════════╪════════════╪═══════════╪════════════╪════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john       ┆ doe       ┆ john.doe@e ┆ software_e ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆            ┆           ┆ xample.com ┆ ngineer    ┆            ┆            ┆        │
│ 2          ┆ jane       ┆ smith     ┆ jane.smith ┆ data_scien ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆            ┆           ┆ @example.c ┆ tist       ┆            ┆            ┆        │
│            ┆            ┆           ┆ om         ┆            ┆            ┆            ┆        │
│ 3          ┆ bob        ┆ johnson   ┆ bob.johnso ┆ product_ma ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆            ┆           ┆ n@example. ┆ nager      ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 4          ┆ alice      ┆ davis     ┆ alice.davi ┆ ux_designe ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆            ┆           ┆ s@example. ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 5          ┆ charlie    ┆ brown     ┆ charlie.br ┆ qa_enginee ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆            ┆           ┆ own@exampl ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ e.com      ┆            ┆            ┆            ┆        │
└────────────┴────────────┴───────────┴────────────┴────────────┴────────────┴────────────┴────────┘
to_upper_snake_case() DataFrame[source]#

Converts column names to UPPER_SNAKE_CASE

Examples

import polars as pl
from polars_extensions import *
data = pl.read_csv('datasets/employees.csv')
data.name_ext.to_kebeb_case()
shape: (5, 8)
┌────────────┬────────────┬───────────┬────────────┬────────────┬────────────┬────────────┬────────┐
│ EMPLOYEE_I ┆ FIRST_NAME ┆ LAST_NAME ┆ EMAIL      ┆ JOB_TITLE  ┆ DATE_OF_BI ┆ DATE_OF_HI ┆ SALARY │
│ D          ┆ ---        ┆ ---       ┆ ---        ┆ ---        ┆ RTH        ┆ RE         ┆ ---    │
│ ---        ┆ str        ┆ str       ┆ str        ┆ str        ┆ ---        ┆ ---        ┆ i64    │
│ i64        ┆            ┆           ┆            ┆            ┆ str        ┆ str        ┆        │
╞════════════╪════════════╪═══════════╪════════════╪════════════╪════════════╪════════════╪════════╡
│ 1          ┆ john       ┆ doe       ┆ john.doe@e ┆ software_e ┆ 1990-05-12 ┆ 2015-08-01 ┆ 85000  │
│            ┆            ┆           ┆ xample.com ┆ ngineer    ┆            ┆            ┆        │
│ 2          ┆ jane       ┆ smith     ┆ jane.smith ┆ data_scien ┆ 1988-11-23 ┆ 2017-03-15 ┆ 95000  │
│            ┆            ┆           ┆ @example.c ┆ tist       ┆            ┆            ┆        │
│            ┆            ┆           ┆ om         ┆            ┆            ┆            ┆        │
│ 3          ┆ bob        ┆ johnson   ┆ bob.johnso ┆ product_ma ┆ 1985-07-19 ┆ 2012-10-10 ┆ 105000 │
│            ┆            ┆           ┆ n@example. ┆ nager      ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 4          ┆ alice      ┆ davis     ┆ alice.davi ┆ ux_designe ┆ 1992-04-06 ┆ 2020-01-21 ┆ 78000  │
│            ┆            ┆           ┆ s@example. ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ com        ┆            ┆            ┆            ┆        │
│ 5          ┆ charlie    ┆ brown     ┆ charlie.br ┆ qa_enginee ┆ 1993-09-14 ┆ 2019-07-08 ┆ 72000  │
│            ┆            ┆           ┆ own@exampl ┆ r          ┆            ┆            ┆        │
│            ┆            ┆           ┆ e.com      ┆            ┆            ┆            ┆        │
└────────────┴────────────┴───────────┴────────────┴────────────┴────────────┴────────────┴────────┘