# rename

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

Renames one or several columns without changing their location in [DataFrame](dataframe.html).

API reference: [rename](https://kotlin.github.io/dataframe/api-docs/core/org.jetbrains.kotlinx.dataframe.api/rename.html)

```KOTLIN
df.rename { columns }.to(name)
df.rename { columns }.to { nameExpression }

nameExpression = (DataColumn) -> String
```

Related operations: [Move / rename / reorder columns](moverename.html)

See [column selectors](columnselectors.html) for how to select the columns for this operation.

Properties:

```KOTLIN
df.rename { name }.to("fullName")
```

Strings:

```KOTLIN
df.rename("name").to("fullName")
```

[Embedded content](resources/org.jetbrains.kotlinx.dataframe.samples.api.Modify.rename.html)

Properties:

```KOTLIN
df.rename { age }.to {
    val mean = it.data.mean()
    "age [mean = $mean]"
}
```

Strings:

```KOTLIN
df.rename("age").to {
    val mean = it.data.cast<Int>().mean()
    "age [mean = $mean]"
}
```

[Embedded content](resources/org.jetbrains.kotlinx.dataframe.samples.api.Modify.renameExpression.html)

## renameToCamelCase

A special case of `rename` that renames all column names in a [DataFrame](dataframe.html) to "camelCase" format.

This function standardizes column names by converting them from various naming styles—such as "snake_case", "PascalCase", "kebab-case", or "space delimited formats" into a consistent "camelCase" form.

The transformation follows Kotlin naming conventions for variables and properties, making the resulting column names idiomatic and easier to use in Kotlin code, which is especially useful in [extension properties usage](extensionpropertiesapi.html).

Use it right after loading raw data to normalize column names into a consistent format. This is especially helpful when preparing the data for further transformations, column access, or integration with Kotlin APIs—making the DataFrame easier and more predictable to work with.

If called on a `ColumnReference`, `renameToCamelCase()` applies the same transformation rules to that column's name and returns a reference with the updated name.

### Examples

```KOTLIN
df
```

[Embedded content](./resources/notebook_test_rename_3.html)

Rename selected columns to "camelCase":

```KOTLIN
df.rename { ColumnA and `COLUMN-C` }.toCamelCase()
```

[Embedded content](./resources/notebook_test_rename_4.html)

Rename all columns (including nested) to "camelCase":

```KOTLIN
df.renameToCamelCase()
```

[Embedded content](./resources/notebook_test_rename_5.html)

### Transformation Rules and Examples

* Delimiters (underscores, dashes, spaces, etc.) are removed.

* The first word is kept lowercase; all subsequent words are capitalized.

* An underscore is inserted between consecutive numbers to improve readability.

* If a name contains no letters or digits, it remains unchanged.

| Original | camelCase |
| --- | --- |
| hello_world | helloWorld |
| HelloWorld | helloWorld |
| json.parser.Config | jsonParserConfig |
| my.var_name test | myVarNameTest |
| thirdColumn | thirdColumn |
| someHTMLParser | someHtmlParser |
| RESTApi | restApi |
| OAuth2Token | oAuth2Token |
| GraphQLQuery | graphQlQuery |
| TCP_3_PROTOCOL | tcp3Protocol |
| 123hello_world456 | 123HelloWorld456 |
| API_Response_2023 | apiResponse2023 |
| UPPER_case-LOWER | upperCaseLower |
| 12parse34CamelCase | 12Parse34CamelCase |
| snake_case_example | snakeCaseExample |
| dot.separated.words | dotSeparatedWords |
| kebab-case-example | kebabCaseExample |
| MIXED_Case_with_123Numbers | mixedCaseWith123Numbers |
| !!! | !!! |
| 1000.2000.3000 | 1000_2000_3000 |
| UPPERCASE | uppercase |
| alreadyCamelCased | alreadyCamelCased |
| justNumbers123 | justNumbers123 |
| Just_Special$Chars!! | justSpecialChars |
| singleword | singleword |
| word_with_underscores_and-dashes | wordWithUnderscoresAndDashes |
| 10-20-aa | 10_20Aa |

