Skip to content

Commit 337341f

Browse files
committed
Remove obsolete column accessors API from docs
1 parent 451544c commit 337341f

File tree

5 files changed

+2
-292
lines changed

5 files changed

+2
-292
lines changed

docs/StardustDocs/d.tree

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
<toc-element topic="overview.md">
1616
<toc-element topic="apiLevels.md">
1717
<toc-element topic="stringApi.md"/>
18-
<toc-element toc-title="Column Accessors API" topic="columnAccessorsApi.md"/>
19-
<toc-element topic="KPropertiesApi.md"/>
2018
<toc-element topic="extensionPropertiesApi.md"/>
2119
</toc-element>
2220
<toc-element topic="hierarchical.md"/>

docs/StardustDocs/topics/DataColumn.md

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -35,127 +35,5 @@ Special case of [`ValueColumn`](#valuecolumn) that stores another [`DataFrame`](
3535

3636
[`DataFrame`](DataFrame.md) stored in [`FrameColumn`](DataColumn.md#framecolumn) may have different schemas.
3737

38-
[`FrameColumn`](DataColumn.md#framecolumn) may appear after [reading](read.md) from JSON or other hierarchical data structures, or after grouping operations such as [groupBy](groupBy.md) or [pivot](pivot.md).
39-
40-
## Column accessors
41-
42-
`ColumnAccessors` are used for [typed data access](columnAccessorsApi.md) in [`DataFrame`](DataFrame.md). `ColumnAccessor` stores column [`name`](#properties) (for top-level columns) or column path (for nested columns), has type argument that corresponds to [`type`](#properties) of thep column, but it doesn't contain any actual data.
43-
44-
<!---FUN columnAccessorsUsage-->
45-
46-
```kotlin
47-
val age by column<Int>()
48-
49-
// Access fourth cell in the "age" column of dataframe `df`.
50-
// This expression returns `Int` because variable `age` has `ColumnAccessor<Int>` type.
51-
// If dataframe `df` has no column "age" or column "age" has type which is incompatible with `Int`,
52-
// runtime exception will be thrown.
53-
df[age][3] + 5
54-
55-
// Access first cell in the "age" column of dataframe `df`.
56-
df[0][age] * 2
57-
58-
// Returns new dataframe sorted by age column (ascending)
59-
df.sortBy(age)
60-
61-
// Returns new dataframe with the column "year of birth" added
62-
df.add("year of birth") { 2021 - age }
63-
64-
// Returns new dataframe containing only rows with age > 30
65-
df.filter { age > 30 }
66-
```
67-
68-
<!---END-->
69-
70-
[Column accessors](DataColumn.md#column-accessors) are created by [property delegate](https://kotlinlang.org/docs/delegated-properties.html) `column`. Column [`type`](DataColumn.md#properties) should be passed as type argument, column [`name`](DataColumn.md#properties) will be taken from the variable name.
71-
72-
<!---FUN createColumnAccessor-->
73-
74-
```kotlin
75-
val name by column<String>()
76-
```
77-
78-
<!---END-->
79-
80-
To assign column name explicitly, pass it as an argument.
81-
82-
<!---FUN createColumnAccessorRenamed-->
83-
84-
```kotlin
85-
val accessor by column<String>("complex column name")
86-
```
87-
88-
<!---END-->
89-
90-
You can also create column accessors for [ColumnGroups](DataColumn.md#columngroup) and [FrameColumns](DataColumn.md#framecolumn)
91-
92-
<!---FUN createGroupOrFrameColumnAccessor-->
93-
94-
```kotlin
95-
val columns by columnGroup()
96-
val frames by frameColumn()
97-
```
98-
99-
<!---END-->
100-
101-
To reference nested columns inside [ColumnGroups](DataColumn.md#columngroup), invoke `column<T>()` on accessor to parent [`ColumnGroup`](#columngroup):
102-
103-
<!---FUN createDeepColumnAccessor-->
104-
105-
```kotlin
106-
val name by columnGroup()
107-
val firstName by name.column<String>()
108-
```
109-
110-
<!---END-->
111-
112-
You can also create virtual accessor that doesn't point to a real column but computes some expression on every data access:
113-
114-
<!---FUN columnAccessorComputed-->
115-
<tabs>
116-
<tab title="Properties">
117-
118-
```kotlin
119-
val fullName by column(df) { name.firstName + " " + name.lastName }
120-
121-
df[fullName]
122-
```
123-
124-
</tab>
125-
<tab title="Strings">
126-
127-
```kotlin
128-
val fullName by column { "name"["firstName"]<String>() + " " + "name"["lastName"]<String>() }
129-
130-
df[fullName]
131-
```
132-
133-
</tab></tabs>
134-
<!---END-->
135-
136-
If expression depends only on one column, you can also use `map`:
137-
138-
<!---FUN columnAccessorMap-->
139-
140-
```kotlin
141-
val age by column<Int>()
142-
val year by age.map { 2021 - it }
143-
144-
df.filter { year > 2000 }
145-
```
146-
147-
<dataFrame src="org.jetbrains.kotlinx.dataframe.samples.api.Create.columnAccessorMap.html"/>
148-
<!---END-->
149-
150-
To convert [`ColumnAccessor`](columnAccessorsApi.md) into [`DataColumn`](DataColumn.md) add values using `withValues` function:
151-
152-
<!---FUN columnAccessorToColumn-->
153-
154-
```kotlin
155-
val age by column<Int>()
156-
val ageCol1 = age.withValues(15, 20)
157-
val ageCol2 = age.withValues(1..10)
158-
```
159-
160-
<!---END-->
38+
[`FrameColumn`](DataColumn.md#framecolumn) may appear after [reading](read.md) from JSON or other hierarchical data structures, or after grouping operations such as [groupBy](groupBy.md) or [pivot](pivot.md).
16139

docs/StardustDocs/topics/KPropertiesApi.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

docs/StardustDocs/topics/apiLevels.md

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ ahead of execution.
1010

1111
That's why creating a flexible, handy, and, at the same time, safe API to a data frame is tricky.
1212

13-
In the Kotlin DataFrame library, we provide four different ways to access columns,
14-
and, while they are essentially different, they
15-
look pretty similar in the data wrangling DSL.
13+
In the Kotlin DataFrame library, we provide two different ways to access columns
1614

1715
## List of Access APIs
1816

@@ -21,13 +19,6 @@ Here's a list of all APIs in order of increasing safety.
2119
* [**String API**](stringApi.md) <br/>
2220
Columns are accessed by `string` representing their name. Type-checking is done at runtime, name-checking too.
2321

24-
* [**Column Accessors API**](columnAccessorsApi.md) <br/>
25-
Every column has a descriptor; a variable that represents its name and type.
26-
27-
* [**KProperties API**](KPropertiesApi.md) <br/>
28-
Columns accessed by the [`KProperty`](https://kotlinlang.org/docs/reflection.html#property-references) of some class.
29-
The name and type of column should match the name and type of property, respectively.
30-
3122
* [**Extension Properties API**](extensionPropertiesApi.md) <br/>
3223
Extension access properties are generated based on the dataframe schema. The name and type of properties are inferred
3324
from the name and type of the corresponding columns.
@@ -61,54 +52,6 @@ DataFrame.read("titanic.csv")
6152

6253
</tab>
6354

64-
<tab title="Column Accessors API">
65-
66-
<!---FUN accessors3-->
67-
68-
```kotlin
69-
val survived by column<Boolean>()
70-
val home by column<String>()
71-
val age by column<Int?>()
72-
val name by column<String>()
73-
val lastName by column<String>()
74-
75-
DataFrame.read("titanic.csv")
76-
.add(lastName) { name().split(",").last() }
77-
.dropNulls { age }
78-
.filter { survived() && home().endsWith("NY") && age()!! in 10..20 }
79-
```
80-
81-
<!---END-->
82-
83-
</tab>
84-
85-
<tab title = "KProperties API">
86-
87-
<!---FUN kproperties1-->
88-
89-
```kotlin
90-
data class Passenger(
91-
val survived: Boolean,
92-
val home: String,
93-
val age: Int,
94-
val lastName: String
95-
)
96-
97-
val passengers = DataFrame.read("titanic.csv")
98-
.add(Passenger::lastName) { "name"<String>().split(",").last() }
99-
.dropNulls(Passenger::age)
100-
.filter {
101-
it[Passenger::survived] &&
102-
it[Passenger::home].endsWith("NY") &&
103-
it[Passenger::age] in 10..20
104-
}
105-
.toListOf<Passenger>()
106-
```
107-
108-
<!---END-->
109-
110-
</tab>
111-
11255
<tab title = "Extension Properties API">
11356

11457
<!---FUN extensionProperties1-->
@@ -145,22 +88,13 @@ df.add("weight") { ... } // add a new column `weight`, calculated by some expres
14588
.sortBy("weight") // sorting dataframe rows by its value
14689
```
14790

148-
We don't need to interrupt a function call chain and declare a column accessor or generate new properties.
149-
15091
In contrast, generated [extension properties](extensionPropertiesApi.md) form the most convenient and the safest API.
15192
Using them, you can always be sure that you work with correct data and types.
15293
However, there's a bottleneck at the moment of generation.
15394
To get new extension properties, you have to run a cell in a notebook,
15495
which could lead to unnecessary variable declarations.
15596
Currently, we are working on a compiler plugin that generates these properties on the fly while typing!
15697

157-
The [Column Accessors API](columnAccessorsApi.md) is a kind of trade-off between safety and needs to be written ahead of
158-
the execution type declaration. It was designed to better be able to write code in an IDE without a notebook experience.
159-
It provides type-safe access to columns but doesn't ensure that the columns really exist in a particular data frame.
160-
161-
The [KProperties API](KPropertiesApi.md) is useful when you already have declared classed in your business
162-
logic with fields that correspond to columns of a data frame.
163-
16498
<table>
16599
<tr>
166100
<td> API </td>
@@ -174,18 +108,6 @@ logic with fields that correspond to columns of a data frame.
174108
<td> Runtime </td>
175109
<td> Runtime </td>
176110
</tr>
177-
<tr>
178-
<td> Column Accessors API </td>
179-
<td> Compile-time </td>
180-
<td> Compile-time </td>
181-
<td> Runtime </td>
182-
</tr>
183-
<tr>
184-
<td> KProperties API </td>
185-
<td> Compile-time </td>
186-
<td> Compile-time </td>
187-
<td> Runtime </td>
188-
</tr>
189111
<tr>
190112
<td> Extension Properties API </td>
191113
<td> Generation-time </td>

docs/StardustDocs/topics/columnAccessorsApi.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)