@@ -5,15 +5,15 @@ import org.jetbrains.kotlinx.dataframe.api.convertTo
55
66/* *
77 * This annotation marks an interface or data class as a [data schema](https://kotlin.github.io/dataframe/schemas.html).
8+ * An annotated declaration should be a non-local and non-private interface or class.
89 *
910 * This annotation generates an extension properties API for a declaration according to its properties.
10- * An annotated declaration should be a non-local and non-private interface or class.
11- * The aim is to provide a convenient syntax for working with a dataframe instance right after reading it from CSV,
11+ * The aim is to provide a convenient class-like syntax for working with a dataframe instance after reading it from CSV,
1212 * JSON, databases, Arrow, or other sources.
1313 *
1414 * After a `val df = DataFrame.read*` operation, `df` is the source of truth for the data schema.
1515 * One way to look at it is that a data schema tells the compiler what is already there; it does not affect reading.
16- * See the related operations in the See also section.
16+ *
1717 * Given the initial schema of the data you read, the
1818 * [compiler plugin](https://github.com/JetBrains/kotlin/tree/master/plugins/kotlin-dataframe) provides a typed result
1919 * for most operations.
@@ -44,15 +44,28 @@ import org.jetbrains.kotlinx.dataframe.api.convertTo
4444 * val df = DataFrame.readJson(url).cast<Group>()
4545 * val groupId: String = df.id[0] // Properties-style access to columns and values.
4646 *
47- * val df1 = df.asGroupBy { participants }.aggregate {
48- * count() into "groupSize"
49- * distinct { city } into "cities"
50- * }
47+ * val df1 = df.asGroupBy { participants }.aggregate {
48+ * count() into "groupSize"
49+ * city.distinct().toList() into "cities"
50+ * }
5151 *
52- * // The compiler plugin uses prior knowledge of `Group` and the aggregate operation to infer new columns.
53- * val cities: List<String> = df1.cities[0]
52+ * // The compiler plugin uses prior knowledge of `Group` and the aggregate operation to infer new columns.
53+ * val cities: List<String? > = df1.cities[0]
5454 * }
5555 * ```
56+ * Schema properties describe the corresponding dataframe columns:
57+ *
58+ * - A property of a regular type `V` corresponds to a `DataColumn<V>`.
59+ * - A property of type `T`, where `T` is annotated with `@DataSchema`, corresponds to a `ColumnGroup<T>`.
60+ * - A property of type `List<T>`, where `T` is annotated with `@DataSchema`, corresponds to a `FrameColumn<T>`.
61+ *
62+ * After casting a dataframe to `DataFrame<Group>`, it can be converted to data-class instances:
63+ * ```kotlin
64+ * val url = "https://raw.githubusercontent.com/Kotlin/dataframe/refs/heads/master/data/participants.json"
65+ * val df = DataFrame.readJson(url).cast<Group>()
66+ * val groups: List<Group> = df.toList()
67+ * val participants: List<Person> = groups.first().participants
68+ * ```
5669 *
5770 * @see [org.jetbrains.kotlinx.dataframe.api.generateDataClasses]
5871 * @see [org.jetbrains.kotlinx.dataframe.api.generateInterfaces]
0 commit comments