@@ -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 *
@@ -72,10 +73,10 @@ internal interface RenameDocs {
7273 * [**`rename`**][rename]**` { `**`columnsSelector: `[`ColumnsSelector`][ColumnsSelector]` `**`}`**
7374 *
7475 * {@include [Indent]}
75- * `| `__`.`__[**`into `**][RenameClause.into ]**`(`**`name : `[`String`][String]**`)`**
76+ * `| `__`.`__[**`to `**][RenameClause.to ]**`(`**`newNames : `[`String`][String]**`, .. )`**
7677 *
7778 * {@include [Indent]}
78- * `| `__`.`__[**`into `**][RenameClause.into ]**` { `**`nameExpression: (`[`ColumnWithPath`][ColumnWithPath]`) -> `[String]` `**`}`**
79+ * `| `__`.`__[**`to `**][RenameClause.to ]**` { `**`nameExpression: (`[`ColumnWithPath`][ColumnWithPath]`) -> `[String]` `**`}`**
7980 *
8081 * {@include [Indent]}
8182 * `| `__`.`__[**`toCamelCase`**][RenameClause.toCamelCase]**`()`**
@@ -115,18 +116,18 @@ private typealias CommonRenameDocs = Nothing
115116@Interpretable(" RenameMapping" )
116117public fun <T > DataFrame<T>.rename (vararg mappings : Pair <String , String >): DataFrame <T > =
117118 rename { mappings.map { it.first.toColumnAccessor() }.toColumnSet() }
118- .into (* mappings.map { it.second }.toTypedArray())
119+ .to (* mappings.map { it.second }.toTypedArray())
119120
120121/* *
121122 * @include [CommonRenameDocs]
122123 * @include [SelectingColumns.ColumnsSelectionDsl] {@include [SetRenameOperationArg]}
123124 * ### Examples:
124125 * ```kotlin
125126 * // Rename "col1" to "width" and "col2" to "length"
126- * df.rename { col1 and col2 }.into ("width", "length")
127+ * df.rename { col1 and col2 }.to ("width", "length")
127128 *
128129 * // Rename all columns using their full path, delimited by "->"
129- * df.rename { colsAtAnyDepth() }.into { it.path.joinToString("->") }
130+ * df.rename { colsAtAnyDepth() }.to { it.path.joinToString("->") }
130131 *
131132 * // Renames all numeric columns to "camelCase"
132133 * df.rename { colsOf<Number>() }.toCamelCase()
@@ -151,7 +152,7 @@ public fun <T, C> DataFrame<T>.rename(vararg cols: KProperty<C>): RenameClause<T
151152 * ### Examples:
152153 * ```kotlin
153154 * // Rename "col1" to "width" and "col2" to "length"
154- * df.rename("col1", "col2").into ("width", "length")
155+ * df.rename("col1", "col2").to ("width", "length")
155156 *
156157 * // Renames "arrival_date" and "passport-ID" columns to "camelCase"
157158 * df.rename("arrival_date", "passport-ID").toCamelCase()
@@ -172,8 +173,8 @@ public fun <T> DataFrame<T>.rename(vararg cols: String): RenameClause<T, Any?> =
172173 * in the [DataFrame], but their names will be changed.
173174 *
174175 * Use the following methods to perform the conversion:
175- * - [into (name)][RenameClause.into ] — renames selected columns to the specified names.
176- * - [into { nameExpression }][RenameClause.into ] — renames selected columns using a custom expression,
176+ * - [to (name)][RenameClause.to ] — renames selected columns to the specified names.
177+ * - [to { nameExpression }][RenameClause.to ] — renames selected columns using a custom expression,
177178 * which takes the column and its path and returns a new name.
178179 * - [toCamelCase()][RenameClause.toCamelCase] — renames all selected columns to `camelCase`.
179180 *
@@ -226,9 +227,12 @@ public fun <T> DataFrame<T>.renameToCamelCase(): DataFrame<T> =
226227@Deprecated(DEPRECATED_ACCESS_API )
227228@AccessApiOverload
228229public fun <T , C > RenameClause <T , C >.into (vararg newColumns : ColumnReference <* >): DataFrame <T > =
229- into (* newColumns.map { it.name() }.toTypedArray())
230+ to (* newColumns.map { it.name() }.toTypedArray())
230231
231232/* *
233+ * __NOTE:__ While you can keep using 'into', we recommend using [to][RenameClause.to] for
234+ * * better readability and more natural English.
235+ *
232236 * Renames the columns selected with [rename] to the specified [newNames],
233237 * preserving their values and positions within the [DataFrame].
234238 *
@@ -254,14 +258,46 @@ public fun <T, C> RenameClause<T, C>.into(vararg newColumns: ColumnReference<*>)
254258 */
255259@Refine
256260@Interpretable(" RenameInto" )
261+ @Deprecated(message = RENAME_INTO , replaceWith = ReplaceWith (" to(*newNames)" ))
257262public fun <T , C > RenameClause <T , C >.into (vararg newNames : String ): DataFrame <T > = renameImpl(newNames)
258263
264+ /* *
265+ * Renames the columns selected with [rename] to the specified [newNames],
266+ * preserving their values and positions within the [DataFrame].
267+ *
268+ * The mapping is positional: [newNames] are applied in the order
269+ * the columns were selected — the first selected column is renamed to the first name,
270+ * the second to the second, and so on.
271+ *
272+ * For more information: {@include [DocumentationUrls.Rename]}
273+ *
274+ * Check out [Grammar][RenameDocs.Grammar].
275+ *
276+ * ### Examples:
277+ * ```kotlin
278+ * // Rename "col1" to "width" and "col2" to "length"
279+ * df.rename("col1", "col2").to("width", "length")
280+ *
281+ * // Rename "col1" to "width" and "col2" to "length"
282+ * df.rename { col1 and col2 }.to("width", "length")
283+ * ```
284+ *
285+ * @param newNames The new names for the selected columns, applied in order of selecting.
286+ * @return A new [DataFrame] with the columns renamed.
287+ */
288+ @Refine
289+ @Interpretable(" RenameInto" )
290+ public fun <T , C > RenameClause <T , C >.to (vararg newNames : String ): DataFrame <T > = renameImpl(newNames)
291+
259292@Deprecated(DEPRECATED_ACCESS_API )
260293@AccessApiOverload
261294public fun <T , C > RenameClause <T , C >.into (vararg newNames : KProperty <* >): DataFrame <T > =
262- into (* newNames.map { it.name }.toTypedArray())
295+ to (* newNames.map { it.name }.toTypedArray())
263296
264297/* *
298+ * __NOTE:__ While you can keep using 'into', we recommend using [to][RenameClause.to] for
299+ * better readability and more natural English.
300+ *
265301 * Renames the columns selected with [rename] by applying the [transform] expression
266302 * to each of them. This expression receives the column together with its full path
267303 * (as [ColumnWithPath]) and must return the new name for that column.
@@ -286,9 +322,37 @@ public fun <T, C> RenameClause<T, C>.into(vararg newNames: KProperty<*>): DataFr
286322 */
287323@Refine
288324@Interpretable(" RenameIntoLambda" )
325+ @Deprecated(message = RENAME_INTO , replaceWith = ReplaceWith (" to(transform)" ))
289326public fun <T , C > RenameClause <T , C >.into (transform : (ColumnWithPath <C >) -> String ): DataFrame <T > =
290327 renameImpl(transform)
291328
329+ /* *
330+ * Renames the columns selected with [rename] by applying the [transform] expression
331+ * to each of them. This expression receives the column together with its full path
332+ * (as [ColumnWithPath]) and must return the new name for that column.
333+ * The operation preserves the original columns’ values and their positions within the [DataFrame].
334+ *
335+ * For more information: {@include [DocumentationUrls.Rename]}
336+ *
337+ * Check out [Grammar][RenameDocs.Grammar] for more details.
338+ *
339+ * ### Examples:
340+ * ```kotlin
341+ * // Rename all columns using their full path, delimited by "->"
342+ * df.rename { colsAtAnyDepth() }.to { it.path.joinToString("->") }
343+ *
344+ * // Rename all `String` columns with uppercase
345+ * df.rename { colsOf<String>() }.to { it.name.uppercase() }
346+ * ```
347+ *
348+ * @param transform A function that takes a [ColumnWithPath] for each selected column
349+ * and returns the new column name.
350+ * @return A new [DataFrame] with the columns renamed.
351+ */
352+ @Refine
353+ @Interpretable(" RenameIntoLambda" )
354+ public fun <T , C > RenameClause <T , C >.to (transform : (ColumnWithPath <C >) -> String ): DataFrame <T > = renameImpl(transform)
355+
292356/* *
293357 * Renames the columns, previously selected with [rename] to "camelCase" format.
294358 *
@@ -321,7 +385,7 @@ public fun <T, C> RenameClause<T, C>.into(transform: (ColumnWithPath<C>) -> Stri
321385 */
322386@Refine
323387@Interpretable(" RenameToCamelCaseClause" )
324- public fun <T , C > RenameClause <T , C >.toCamelCase (): DataFrame <T > = into { it.renameToCamelCase().name() }
388+ public fun <T , C > RenameClause <T , C >.toCamelCase (): DataFrame <T > = to { it.renameToCamelCase().name() }
325389
326390// endregion
327391
0 commit comments