@@ -27,6 +27,7 @@ import org.jetbrains.kotlinx.dataframe.impl.columnName
2727import org.jetbrains.kotlinx.dataframe.impl.columns.renamedColumn
2828import org.jetbrains.kotlinx.dataframe.impl.toCamelCaseByDelimiters
2929import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API
30+ import org.jetbrains.kotlinx.dataframe.util.RENAME_INTO
3031import kotlin.reflect.KProperty
3132
3233// region DataFrame
@@ -38,8 +39,8 @@ import kotlin.reflect.KProperty
3839 * returns a [RenameClause],
3940 * which serves as an intermediate step.
4041 * The [RenameClause] object provides methods to rename selected columns using:
41- * - [into (name)][RenameClause.into ] - renames selected columns to the specified names.
42- * - [into { nameExpression }][RenameClause.into ] - renames selected columns using a provided
42+ * - [to (name)][RenameClause.to ] - renames selected columns to the specified names.
43+ * - [to { nameExpression }][RenameClause.to ] - renames selected columns using a provided
4344 * expression assuming column with its path and returning a new name.
4445 * - [toCamelCase()][RenameClause.toCamelCase] - renames all selected columns to "camelCase".
4546 *
@@ -127,10 +128,10 @@ internal interface RenameDocs {
127128 * [**`rename`**][rename]**` { `**`columnsSelector: `[`ColumnsSelector`][ColumnsSelector]` `**`}`**
128129 *
129130 *
130- * `| `__`.`__[**`into `**][RenameClause.into ]**`(`**`name : `[`String`][String]**`)`**
131+ * `| `__`.`__[**`to `**][RenameClause.to ]**`(`**`newNames : `[`String`][String]**`, .. )`**
131132 *
132133 *
133- * `| `__`.`__[**`into `**][RenameClause.into ]**` { `**`nameExpression: (`[`ColumnWithPath`][ColumnWithPath]`) -> `[String]` `**`}`**
134+ * `| `__`.`__[**`to `**][RenameClause.to ]**` { `**`nameExpression: (`[`ColumnWithPath`][ColumnWithPath]`) -> `[String]` `**`}`**
134135 *
135136 *
136137 * `| `__`.`__[**`toCamelCase`**][RenameClause.toCamelCase]**`()`**
@@ -159,7 +160,7 @@ internal interface RenameDocs {
159160@Interpretable(" RenameMapping" )
160161public fun <T > DataFrame<T>.rename (vararg mappings : Pair <String , String >): DataFrame <T > =
161162 rename { mappings.map { it.first.toColumnAccessor() }.toColumnSet() }
162- .into (* mappings.map { it.second }.toTypedArray())
163+ .to (* mappings.map { it.second }.toTypedArray())
163164
164165/* *
165166 * Renames the specified [columns] keeping their original values and location within the [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame].
@@ -168,8 +169,8 @@ public fun <T> DataFrame<T>.rename(vararg mappings: Pair<String, String>): DataF
168169 * returns a [RenameClause][org.jetbrains.kotlinx.dataframe.api.RenameClause],
169170 * which serves as an intermediate step.
170171 * The [RenameClause][org.jetbrains.kotlinx.dataframe.api.RenameClause] object provides methods to rename selected columns using:
171- * - [into (name)][org.jetbrains.kotlinx.dataframe.api.RenameClause.into ] - renames selected columns to the specified names.
172- * - [into { nameExpression }][org.jetbrains.kotlinx.dataframe.api.RenameClause.into ] - renames selected columns using a provided
172+ * - [to (name)][org.jetbrains.kotlinx.dataframe.api.RenameClause.to ] - renames selected columns to the specified names.
173+ * - [to { nameExpression }][org.jetbrains.kotlinx.dataframe.api.RenameClause.to ] - renames selected columns using a provided
173174 * expression assuming column with its path and returning a new name.
174175 * - [toCamelCase()][org.jetbrains.kotlinx.dataframe.api.RenameClause.toCamelCase] - renames all selected columns to "camelCase".
175176 *
@@ -205,10 +206,10 @@ public fun <T> DataFrame<T>.rename(vararg mappings: Pair<String, String>): DataF
205206 * ### Examples:
206207 * ```kotlin
207208 * // Rename "col1" to "width" and "col2" to "length"
208- * df.rename { col1 and col2 }.into ("width", "length")
209+ * df.rename { col1 and col2 }.to ("width", "length")
209210 *
210211 * // Rename all columns using their full path, delimited by "->"
211- * df.rename { colsAtAnyDepth() }.into { it.path.joinToString("->") }
212+ * df.rename { colsAtAnyDepth() }.to { it.path.joinToString("->") }
212213 *
213214 * // Renames all numeric columns to "camelCase"
214215 * df.rename { colsOf<Number>() }.toCamelCase()
@@ -234,8 +235,8 @@ public fun <T, C> DataFrame<T>.rename(vararg cols: KProperty<C>): RenameClause<T
234235 * returns a [RenameClause][org.jetbrains.kotlinx.dataframe.api.RenameClause],
235236 * which serves as an intermediate step.
236237 * The [RenameClause][org.jetbrains.kotlinx.dataframe.api.RenameClause] object provides methods to rename selected columns using:
237- * - [into (name)][org.jetbrains.kotlinx.dataframe.api.RenameClause.into ] - renames selected columns to the specified names.
238- * - [into { nameExpression }][org.jetbrains.kotlinx.dataframe.api.RenameClause.into ] - renames selected columns using a provided
238+ * - [to (name)][org.jetbrains.kotlinx.dataframe.api.RenameClause.to ] - renames selected columns to the specified names.
239+ * - [to { nameExpression }][org.jetbrains.kotlinx.dataframe.api.RenameClause.to ] - renames selected columns using a provided
239240 * expression assuming column with its path and returning a new name.
240241 * - [toCamelCase()][org.jetbrains.kotlinx.dataframe.api.RenameClause.toCamelCase] - renames all selected columns to "camelCase".
241242 *
@@ -260,7 +261,7 @@ public fun <T, C> DataFrame<T>.rename(vararg cols: KProperty<C>): RenameClause<T
260261 * ### Examples:
261262 * ```kotlin
262263 * // Rename "col1" to "width" and "col2" to "length"
263- * df.rename("col1", "col2").into ("width", "length")
264+ * df.rename("col1", "col2").to ("width", "length")
264265 *
265266 * // Renames "arrival_date" and "passport-ID" columns to "camelCase"
266267 * df.rename("arrival_date", "passport-ID").toCamelCase()
@@ -281,8 +282,8 @@ public fun <T> DataFrame<T>.rename(vararg cols: String): RenameClause<T, Any?> =
281282 * in the [DataFrame], but their names will be changed.
282283 *
283284 * Use the following methods to perform the conversion:
284- * - [into (name)][RenameClause.into ] — renames selected columns to the specified names.
285- * - [into { nameExpression }][RenameClause.into ] — renames selected columns using a custom expression,
285+ * - [to (name)][RenameClause.to ] — renames selected columns to the specified names.
286+ * - [to { nameExpression }][RenameClause.to ] — renames selected columns using a custom expression,
286287 * which takes the column and its path and returns a new name.
287288 * - [toCamelCase()][RenameClause.toCamelCase] — renames all selected columns to `camelCase`.
288289 *
@@ -335,9 +336,12 @@ public fun <T> DataFrame<T>.renameToCamelCase(): DataFrame<T> =
335336@Deprecated(DEPRECATED_ACCESS_API )
336337@AccessApiOverload
337338public fun <T , C > RenameClause <T , C >.into (vararg newColumns : ColumnReference <* >): DataFrame <T > =
338- into (* newColumns.map { it.name() }.toTypedArray())
339+ to (* newColumns.map { it.name() }.toTypedArray())
339340
340341/* *
342+ * __NOTE:__ While you can keep using 'into', we recommend using [to][RenameClause.to] for
343+ * * better readability and more natural English.
344+ *
341345 * Renames the columns selected with [rename] to the specified [newNames],
342346 * preserving their values and positions within the [DataFrame].
343347 *
@@ -363,14 +367,46 @@ public fun <T, C> RenameClause<T, C>.into(vararg newColumns: ColumnReference<*>)
363367 */
364368@Refine
365369@Interpretable(" RenameInto" )
370+ @Deprecated(message = RENAME_INTO , replaceWith = ReplaceWith (" to(*newNames)" ))
366371public fun <T , C > RenameClause <T , C >.into (vararg newNames : String ): DataFrame <T > = renameImpl(newNames)
367372
373+ /* *
374+ * Renames the columns selected with [rename] to the specified [newNames],
375+ * preserving their values and positions within the [DataFrame].
376+ *
377+ * The mapping is positional: [newNames] are applied in the order
378+ * the columns were selected — the first selected column is renamed to the first name,
379+ * the second to the second, and so on.
380+ *
381+ * For more information: [See `rename` on the documentation website.](https://kotlin.github.io/dataframe/rename.html)
382+ *
383+ * Check out [Grammar][RenameDocs.Grammar].
384+ *
385+ * ### Examples:
386+ * ```kotlin
387+ * // Rename "col1" to "width" and "col2" to "length"
388+ * df.rename("col1", "col2").to("width", "length")
389+ *
390+ * // Rename "col1" to "width" and "col2" to "length"
391+ * df.rename { col1 and col2 }.to("width", "length")
392+ * ```
393+ *
394+ * @param newNames The new names for the selected columns, applied in order of selecting.
395+ * @return A new [DataFrame] with the columns renamed.
396+ */
397+ @Refine
398+ @Interpretable(" RenameInto" )
399+ public fun <T , C > RenameClause <T , C >.to (vararg newNames : String ): DataFrame <T > = renameImpl(newNames)
400+
368401@Deprecated(DEPRECATED_ACCESS_API )
369402@AccessApiOverload
370403public fun <T , C > RenameClause <T , C >.into (vararg newNames : KProperty <* >): DataFrame <T > =
371- into (* newNames.map { it.name }.toTypedArray())
404+ to (* newNames.map { it.name }.toTypedArray())
372405
373406/* *
407+ * __NOTE:__ While you can keep using 'into', we recommend using [to][RenameClause.to] for
408+ * better readability and more natural English.
409+ *
374410 * Renames the columns selected with [rename] by applying the [transform] expression
375411 * to each of them. This expression receives the column together with its full path
376412 * (as [ColumnWithPath]) and must return the new name for that column.
@@ -395,9 +431,37 @@ public fun <T, C> RenameClause<T, C>.into(vararg newNames: KProperty<*>): DataFr
395431 */
396432@Refine
397433@Interpretable(" RenameIntoLambda" )
434+ @Deprecated(message = RENAME_INTO , replaceWith = ReplaceWith (" to(transform)" ))
398435public fun <T , C > RenameClause <T , C >.into (transform : (ColumnWithPath <C >) -> String ): DataFrame <T > =
399436 renameImpl(transform)
400437
438+ /* *
439+ * Renames the columns selected with [rename] by applying the [transform] expression
440+ * to each of them. This expression receives the column together with its full path
441+ * (as [ColumnWithPath]) and must return the new name for that column.
442+ * The operation preserves the original columns’ values and their positions within the [DataFrame].
443+ *
444+ * For more information: [See `rename` on the documentation website.](https://kotlin.github.io/dataframe/rename.html)
445+ *
446+ * Check out [Grammar][RenameDocs.Grammar] for more details.
447+ *
448+ * ### Examples:
449+ * ```kotlin
450+ * // Rename all columns using their full path, delimited by "->"
451+ * df.rename { colsAtAnyDepth() }.to { it.path.joinToString("->") }
452+ *
453+ * // Rename all `String` columns with uppercase
454+ * df.rename { colsOf<String>() }.to { it.name.uppercase() }
455+ * ```
456+ *
457+ * @param transform A function that takes a [ColumnWithPath] for each selected column
458+ * and returns the new column name.
459+ * @return A new [DataFrame] with the columns renamed.
460+ */
461+ @Refine
462+ @Interpretable(" RenameIntoLambda" )
463+ public fun <T , C > RenameClause <T , C >.to (transform : (ColumnWithPath <C >) -> String ): DataFrame <T > = renameImpl(transform)
464+
401465/* *
402466 * Renames the columns, previously selected with [rename] to "camelCase" format.
403467 *
@@ -430,7 +494,7 @@ public fun <T, C> RenameClause<T, C>.into(transform: (ColumnWithPath<C>) -> Stri
430494 */
431495@Refine
432496@Interpretable(" RenameToCamelCaseClause" )
433- public fun <T , C > RenameClause <T , C >.toCamelCase (): DataFrame <T > = into { it.renameToCamelCase().name() }
497+ public fun <T , C > RenameClause <T , C >.toCamelCase (): DataFrame <T > = to { it.renameToCamelCase().name() }
434498
435499// endregion
436500
0 commit comments