Skip to content

Commit 5bae854

Browse files
add shortcuts
1 parent dc57748 commit 5bae854

File tree

1 file changed

+47
-0
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api

1 file changed

+47
-0
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/move.kt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,53 @@ public fun <T> DataFrame<T>.moveTo(newColumnIndex: Int, vararg columns: AnyColum
220220
public fun <T> DataFrame<T>.moveTo(newColumnIndex: Int, vararg columns: KProperty<*>): DataFrame<T> =
221221
moveTo(newColumnIndex) { columns.toColumnSet() }
222222

223+
/**
224+
* Moves the specified [columns\] to a new position specified
225+
* by [columnIndex]. If [insideGroup] is true selected columns
226+
* will be moved remaining within their [ColumnGroup],
227+
* else they will be moved to the top level.
228+
*
229+
* @include [CommonMoveToDocs]
230+
* @include [SelectingColumns.Dsl] {@include [SetMoveToOperationArg]}
231+
* ### Examples:
232+
* ```kotlin
233+
* df.moveTo(0, true) { length and age }
234+
* df.moveTo(2, false) { cols(1..5) }
235+
* ```
236+
* @param [newColumnIndex] The index specifying the position in the [DataFrame] columns
237+
* where the selected columns will be moved.
238+
* @param [insideGroup] If true, selected columns will be moved remaining inside their group,
239+
* else they will be moved to the top level.
240+
* @param [columns\] The [Columns Selector][ColumnsSelector] used to select the columns of this [DataFrame] to move.
241+
*/
242+
public fun <T> DataFrame<T>.moveTo(
243+
newColumnIndex: Int,
244+
insideGroup: Boolean,
245+
columns: ColumnsSelector<T, *>,
246+
): DataFrame<T> = move(columns).to(newColumnIndex, insideGroup)
247+
248+
/**
249+
* * Moves the specified [columns\] to a new position specified
250+
* * by [columnIndex]. If [insideGroup] is true selected columns
251+
* * will be moved remaining within their [ColumnGroup],
252+
* * else they will be moved to the top level.
253+
*
254+
* @include [CommonMoveToDocs]
255+
* @include [SelectingColumns.ColumnNames] {@include [SetMoveToOperationArg]}
256+
* ### Examples:
257+
* ```kotlin
258+
* df.moveTo(0, true) { length and age }
259+
* df.moveTo(2, false) { cols(1..5) }
260+
* ```
261+
* @param [newColumnIndex] The index specifying the position in the [DataFrame] columns
262+
* where the selected columns will be moved.
263+
* @param [insideGroup] If true, selected columns will be moved remaining inside their group,
264+
* else they will be moved to the top level.
265+
* @param [columns\] The [Columns Selector][ColumnsSelector] used to select the columns of this [DataFrame] to move.
266+
*/
267+
public fun <T> DataFrame<T>.moveTo(newColumnIndex: Int, insideGroup: Boolean, vararg columns: String): DataFrame<T> =
268+
moveTo(newColumnIndex, insideGroup) { columns.toColumnSet() }
269+
223270
// endregion
224271

225272
// region moveToStart

0 commit comments

Comments
 (0)