@@ -4,48 +4,53 @@ import org.jetbrains.kotlinx.dataframe.api.cast
44import org.jetbrains.kotlinx.dataframe.api.convertTo
55
66/* *
7- * Annotation to generate extension properties API for a given declaration, according to its properties.
8- * Annotated declaration should be non-local and non-private interface or a class.
9- * The aim here is to provide convenient syntax for working with a dataframe instance right after reading from it CSV, JSON, Databases, Arrow, etc.
10- * After `val df = DataFrame.read*` operation, `df` is a source of truth for the DataSchema.
11- * One way to look at it, DataSchema "tells" the compiler what's already there. It doesn't affect reading.
12- * See the list below of code generation methods to simplify the process of getting what we call an initial dataschema.
13- * Given the initial schema of the data you read, the compiler plugin will provide a typed result for most operations.
7+ * This annotation marks an interface or data class as a [data schema](https://kotlin.github.io/dataframe/schemas.html).
8+ *
9+ * 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,
12+ * JSON, databases, Arrow, or other sources.
13+ *
14+ * After a `val df = DataFrame.read*` operation, `df` is the source of truth for the data schema.
15+ * 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.
17+ * Given the initial schema of the data you read, the
18+ * [compiler plugin](https://github.com/JetBrains/kotlin/tree/master/plugins/kotlin-dataframe) provides a typed result
19+ * for most operations.
1420 *
1521 * Example:
16- * ```
22+ * ```kotlin
1723 * @DataSchema
1824 * data class Group(
19- * val id: String,
20- * val participants: List<Person>
25+ * val id: String, // DataColumn<String>
26+ * val participants: List<Person>, // FrameColumn<Person>
2127 * )
2228 *
2329 * @DataSchema
2430 * data class Person(
25- * val name: Name,
26- * val age: Int,
27- * val city: String?
31+ * val name: Name, // ColumnGroup<Name>
32+ * val age: Int, // DataColumn<Int>
33+ * val city: String?, // DataColumn<String?>
2834 * )
2935 *
3036 * @DataSchema
3137 * data class Name(
32- * val firstName: String,
33- * val lastName: String,
38+ * val firstName: String, // DataColumn<String>
39+ * val lastName: String, // DataColumn<String>
3440 * )
3541 *
3642 * fun main() {
37- * val url = "https://raw.githubusercontent.com/Kotlin/dataframe/refs/heads/master/data/participants.json"
38- * val df = DataFrame.readJson(url).cast<Group>()
39- * val i: Int = df.id[0] // properties style access to columns and values
40- *
41- * val df1 = df.asGroupBy { participants }.aggregate {
42- * count() into "groupSize"
43- * distinct { city } into "cities"
44- * }
45- *
46- * // now compiler plugin uses previous knowledge of `Group` combined with its understanding of aggregate operation
47- * // to help you access new columns
48- * val l: List<String> = df1.cities[0]
43+ * val url = "https://raw.githubusercontent.com/Kotlin/dataframe/refs/heads/master/data/participants.json"
44+ * val df = DataFrame.readJson(url).cast<Group>()
45+ * val groupId: String = df.id[0] // Properties-style access to columns and values.
46+ *
47+ * val df1 = df.asGroupBy { participants }.aggregate {
48+ * count() into "groupSize"
49+ * distinct { city } into "cities"
50+ * }
51+ *
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]
4954 * }
5055 * ```
5156 *
0 commit comments