Skip to content

Commit 2b1d7c3

Browse files
authored
Merge pull request #1134 from Kotlin/convert_kdocs
Convert KDocs
2 parents 192eaf2 + d1ea42d commit 2b1d7c3

File tree

36 files changed

+3281
-173
lines changed

36 files changed

+3281
-173
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt

Lines changed: 1639 additions & 50 deletions
Large diffs are not rendered by default.

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cumSum.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public fun <T : Number?> DataColumn<T>.cumSum(skipNA: Boolean = defaultCumSumSki
222222
public fun <T, C : Number?> DataFrame<T>.cumSum(
223223
skipNA: Boolean = defaultCumSumSkipNA,
224224
columns: ColumnsSelector<T, C>,
225-
): DataFrame<T> = convert(columns).to { it.cumSum(skipNA) }
225+
): DataFrame<T> = convert(columns).asColumn { it.cumSum(skipNA) }
226226

227227
/**
228228
* ## The CumSum Operation

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/group.kt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,26 @@ public fun <T, C> GroupClause<T, C>.into(column: ColumnsSelectionDsl<T>.(ColumnW
305305
*
306306
* For more information: [See `group` on the documentation website.](https://kotlin.github.io/dataframe/group.html)
307307
*
308-
* Select columns using their [column names][String]
309-
* ([String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi]).
308+
* Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl].
309+
* (Any (combination of) [Access API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi]).
310+
*
311+
* This DSL is initiated by a [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] lambda,
312+
* which operates in the context of the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl] and
313+
* expects you to return a [SingleColumn][org.jetbrains.kotlinx.dataframe.columns.SingleColumn] or [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] (so, a [ColumnsResolver][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver]).
314+
* This is an entity formed by calling any (combination) of the functions
315+
* in the DSL that is or can be resolved into one or more columns.
316+
*
317+
* #### NOTE:
318+
* While you can use the [String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi] and [KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]
319+
* in this DSL directly with any function, they are NOT valid return types for the
320+
* [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] lambda. You'd need to turn them into a [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] first, for instance
321+
* with a function like [`col("name")`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.col].
322+
*
323+
* ### Check out: [Columns Selection DSL Grammar][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.DslGrammar]
324+
*
325+
* &nbsp;&nbsp;&nbsp;&nbsp;
326+
*
327+
* [See Column Selectors on the documentation website.](https://kotlin.github.io/dataframe/columnselectors.html)
310328
*
311329
* ### Examples:
312330
* ```kotlin

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ public fun <T, C> Update<T, C>.at(rowRange: IntRange): Update<T, C> = where { in
432432
*
433433
*
434434
* ## See Also
435-
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row.
435+
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row
436+
* and its previous value.
436437
* - [Update per col][org.jetbrains.kotlinx.dataframe.api.Update.perCol] to provide a new value for every selected cell giving its column.
437438
* @param [expression] The [Row Column Expression][org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRowAndColumn.RowColumnExpression] to provide a new value for every selected cell giving its row and column.
438439
*/
@@ -459,7 +460,9 @@ public typealias UpdateExpression<T, C, R> = AddDataRow<T>.(C) -> R
459460
*
460461
*
461462
* ## Note
462-
* [update with][org.jetbrains.kotlinx.dataframe.api.Update.with]- and [add][org.jetbrains.kotlinx.dataframe.api.add]-like expressions use [AddDataRow][org.jetbrains.kotlinx.dataframe.api.AddDataRow] instead of [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as the DSL's receiver type.
463+
* [update with][org.jetbrains.kotlinx.dataframe.api.Update.with]-,
464+
* [convert with][org.jetbrains.kotlinx.dataframe.api.Convert.with]-
465+
* and [add][org.jetbrains.kotlinx.dataframe.api.add]-like expressions use [AddDataRow][org.jetbrains.kotlinx.dataframe.api.AddDataRow] instead of [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as the DSL's receiver type.
463466
* This is an extension to [RowValueExpression][org.jetbrains.kotlinx.dataframe.RowValueExpression] and
464467
* [RowExpression][org.jetbrains.kotlinx.dataframe.RowExpression] that provides access to
465468
* the modified/generated value of the preceding row ([AddDataRow.newValue][org.jetbrains.kotlinx.dataframe.api.AddDataRow.newValue]).
@@ -499,7 +502,8 @@ public fun <T, C, R> Update<T, DataRow<C>>.asFrame(expression: DataFrameExpressi
499502
* or [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as Map.
500503
*
501504
* ### See Also
502-
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row.
505+
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row
506+
* and its previous value.
503507
* - [Update per row col][org.jetbrains.kotlinx.dataframe.api.Update.perRowCol] to provide a new value for every selected cell giving its row and column.
504508
* ### This Per Col Overload
505509
* Provide a new value for every selected cell per column using a [Map][Map]`<`[colName: String][String]`, value: C>`
@@ -531,7 +535,8 @@ public fun <T, C> Update<T, C>.perCol(values: Map<String, C>): DataFrame<T> =
531535
* or [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as Map.
532536
*
533537
* ### See Also
534-
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row.
538+
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row
539+
* and its previous value.
535540
* - [Update per row col][org.jetbrains.kotlinx.dataframe.api.Update.perRowCol] to provide a new value for every selected cell giving its row and column.
536541
* ### This Per Col Overload
537542
* Provide a new value for every selected cell per column using a [Map][Map]`<`[colName: String][String]`, value: C>`
@@ -565,7 +570,8 @@ public fun <T, C> Update<T, C>.perCol(values: AnyRow): DataFrame<T> = perCol(val
565570
* or [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as Map.
566571
*
567572
* ### See Also
568-
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row.
573+
* - [Update with][org.jetbrains.kotlinx.dataframe.api.Update.with] to provide a new value for every selected cell giving its row
574+
* and its previous value.
569575
* - [Update per row col][org.jetbrains.kotlinx.dataframe.api.Update.perRowCol] to provide a new value for every selected cell giving its row and column.
570576
* ### This Per Col Overload
571577
* Provide a new value for every selected cell given its column using a [column expression][org.jetbrains.kotlinx.dataframe.ColumnExpression].

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRow.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import org.jetbrains.kotlinx.dataframe.RowValueExpression as DfRowValueExpressio
2828
*
2929
* NOTE:
3030
*
31-
* [update with][org.jetbrains.kotlinx.dataframe.api.Update.with]- and [add][org.jetbrains.kotlinx.dataframe.api.add]-like expressions use [AddDataRow][org.jetbrains.kotlinx.dataframe.api.AddDataRow] instead of [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as the DSL's receiver type.
31+
* [update with][org.jetbrains.kotlinx.dataframe.api.Update.with]-,
32+
* [convert with][org.jetbrains.kotlinx.dataframe.api.Convert.with]-
33+
* and [add][org.jetbrains.kotlinx.dataframe.api.add]-like expressions use [AddDataRow][org.jetbrains.kotlinx.dataframe.api.AddDataRow] instead of [DataRow][org.jetbrains.kotlinx.dataframe.DataRow] as the DSL's receiver type.
3234
* This is an extension to [RowValueExpression][org.jetbrains.kotlinx.dataframe.RowValueExpression] and
3335
* [RowExpression][org.jetbrains.kotlinx.dataframe.RowExpression] that provides access to
3436
* the modified/generated value of the preceding row ([AddDataRow.newValue][org.jetbrains.kotlinx.dataframe.api.AddDataRow.newValue]).
@@ -48,7 +50,9 @@ internal interface ExpressionsGivenRow {
4850
interface SetDefaultOperationArg
4951

5052
/**
51-
* [update with][org.jetbrains.kotlinx.dataframe.api.Update.with]- and [add][org.jetbrains.kotlinx.dataframe.api.add]-like expressions use [AddDataRow] instead of [DataRow] as the DSL's receiver type.
53+
* [update with][org.jetbrains.kotlinx.dataframe.api.Update.with]-,
54+
* [convert with][org.jetbrains.kotlinx.dataframe.api.Convert.with]-
55+
* and [add][org.jetbrains.kotlinx.dataframe.api.add]-like expressions use [AddDataRow] instead of [DataRow] as the DSL's receiver type.
5256
* This is an extension to [RowValueExpression][DfRowValueExpression] and
5357
* [RowExpression][DfRowExpression] that provides access to
5458
* the modified/generated value of the preceding row ([AddDataRow.newValue]).

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.jetbrains.kotlinx.dataframe.api.Convert
2626
import org.jetbrains.kotlinx.dataframe.api.DataSchemaEnum
2727
import org.jetbrains.kotlinx.dataframe.api.Infer
2828
import org.jetbrains.kotlinx.dataframe.api.ParserOptions
29+
import org.jetbrains.kotlinx.dataframe.api.asColumn
2930
import org.jetbrains.kotlinx.dataframe.api.mapIndexed
3031
import org.jetbrains.kotlinx.dataframe.api.name
3132
import org.jetbrains.kotlinx.dataframe.api.to
@@ -70,7 +71,7 @@ internal fun <T, C, R> Convert<T, C>.withRowCellImpl(
7071
infer: Infer,
7172
rowConverter: RowValueExpression<T, C, R>,
7273
): DataFrame<T> =
73-
to { col ->
74+
asColumn { col ->
7475
try {
7576
df.newColumn(type, col.name, infer) { rowConverter(it, it[col]) }
7677
} catch (e: ClassCastException) {
@@ -85,7 +86,7 @@ internal fun <T, C, R> Convert<T, C>.convertRowColumnImpl(
8586
type: KType,
8687
infer: Infer,
8788
rowConverter: RowColumnExpression<T, C, R>,
88-
): DataFrame<T> = to { col -> df.newColumn(type, col.name, infer) { rowConverter(it, col) } }
89+
): DataFrame<T> = asColumn { col -> df.newColumn(type, col.name, infer) { rowConverter(it, col) } }
8990

9091
/**
9192
* Specific implementation for [convertToTypeImpl] for [String] -> [Double] conversion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame
1818
import org.jetbrains.kotlinx.dataframe.DataRow
1919
import org.jetbrains.kotlinx.dataframe.api.GlobalParserOptions
2020
import org.jetbrains.kotlinx.dataframe.api.ParserOptions
21+
import org.jetbrains.kotlinx.dataframe.api.asColumn
2122
import org.jetbrains.kotlinx.dataframe.api.asColumnGroup
2223
import org.jetbrains.kotlinx.dataframe.api.asDataColumn
2324
import org.jetbrains.kotlinx.dataframe.api.cast
@@ -26,7 +27,6 @@ import org.jetbrains.kotlinx.dataframe.api.isColumnGroup
2627
import org.jetbrains.kotlinx.dataframe.api.isFrameColumn
2728
import org.jetbrains.kotlinx.dataframe.api.isSubtypeOf
2829
import org.jetbrains.kotlinx.dataframe.api.map
29-
import org.jetbrains.kotlinx.dataframe.api.to
3030
import org.jetbrains.kotlinx.dataframe.columns.TypeSuggestion
3131
import org.jetbrains.kotlinx.dataframe.columns.size
3232
import org.jetbrains.kotlinx.dataframe.exceptions.TypeConversionException
@@ -673,7 +673,7 @@ internal fun <T> DataColumn<String?>.parse(parser: StringParser<T>, options: Par
673673
}
674674

675675
internal fun <T> DataFrame<T>.parseImpl(options: ParserOptions?, columns: ColumnsSelector<T, Any?>): DataFrame<T> =
676-
convert(columns).to { col ->
676+
convert(columns).asColumn { col ->
677677
when {
678678
// when a frame column is requested to be parsed,
679679
// parse each value/frame column at any depth inside each DataFrame in the frame column

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/common.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ public fun catchHttpResponse(url: URL, body: (InputStream) -> AnyFrame): AnyFram
4444
}
4545
}
4646

47+
/**
48+
* Converts a list of lists into a [DataFrame].
49+
*
50+
* By default, treats the first inner list as a header (column names), and the remaining lists as rows.
51+
* If [containsColumns] is `true`, interprets each inner list as a column,
52+
* where the first element is used as the column name, and the remaining elements as values.
53+
*
54+
* @param T The type of elements contained in the nested lists.
55+
* @param containsColumns If `true`, treats each nested list as a column with its first element as the column name.
56+
* Otherwise, the first list is treated as the header.
57+
* Defaults to `false`.
58+
* @return A [DataFrame] containing the data from the nested list structure.
59+
* Returns an empty [DataFrame] if the input is empty or invalid.
60+
*/
4761
public fun <T> List<List<T>>.toDataFrame(containsColumns: Boolean = false): AnyFrame =
4862
when {
4963
containsColumns -> {

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ internal const val MAX_NO_SKIPNAN = "This function is just here for binary compa
9292
internal const val MIN_NO_SKIPNAN = "This function is just here for binary compatibility. $MESSAGE_0_16"
9393
internal const val MEAN_NO_SKIPNAN = "This function is just here for binary compatibility. $MESSAGE_0_16"
9494

95+
internal const val CONVERT_TO = "This to overload will be removed in favor of `asColumn`. $MESSAGE_0_16"
96+
internal const val CONVERT_TO_REPLACE = "this.asColumn(columnConverter)"
97+
9598
// endregion
9699

97100
// region WARNING in 0.16, ERROR in 0.17

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ open class ColumnsSelectionDslTests : TestBase() {
1818

1919
protected val dfWithFrames = df
2020
.add { expr { df } into frameCol }
21-
.convert { name }.to {
21+
.convert { name }.asColumn {
2222
val firstName by it.asColumnGroup().firstName
2323
val lastName by it.asColumnGroup().lastName
2424

0 commit comments

Comments
 (0)