Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e9a396

Browse files
committed
update README with copy-paste snippets for better first hands-on experience
1 parent 4991b2d commit 2e9a396

File tree

2 files changed

+68
-122
lines changed

2 files changed

+68
-122
lines changed

README.md

Lines changed: 58 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -37,143 +37,65 @@ You could find the following articles there:
3737

3838
## Setup
3939

40-
### Gradle for JVM
41-
```groovy
42-
// build.gradle
43-
44-
plugins {
45-
// Optional Gradle plugin for enhanced type safety and schema generation
46-
// https://kotlin.github.io/dataframe/gradle.html
47-
id 'org.jetbrains.kotlinx.dataframe' version '0.12.0'
48-
}
49-
50-
repositories {
51-
mavenCentral()
52-
}
53-
54-
dependencies {
55-
implementation 'org.jetbrains.kotlinx:dataframe:0.12.0'
56-
}
40+
```kotlin
41+
implementation("org.jetbrains.kotlinx:dataframe:0.12.0")
5742
```
5843

44+
Optional Gradle plugin for enhanced type safety and schema generation
45+
https://kotlin.github.io/dataframe/schemasgradle.html
5946
```kotlin
60-
// build.gradle.kts
61-
62-
plugins {
63-
// Optional Gradle plugin for enhanced type safety and schema generation
64-
// https://kotlin.github.io/dataframe/gradle.html
65-
id("org.jetbrains.kotlinx.dataframe") version "0.12.0"
66-
}
67-
68-
repositories {
69-
mavenCentral()
70-
}
71-
72-
dependencies {
73-
implementation("org.jetbrains.kotlinx:dataframe:0.12.0")
74-
}
47+
id("org.jetbrains.kotlinx.dataframe") version "0.12.0"
7548
```
7649

77-
### Gradle for Android
78-
```groovy
79-
// build.gradle
80-
81-
plugins {
82-
// Optional Gradle plugin for enhanced type safety and schema generation
83-
// https://kotlin.github.io/dataframe/gradle.html
84-
id 'org.jetbrains.kotlinx.dataframe' version '0.12.0'
85-
}
50+
Check out [custom setup page](https://kotlin.github.io/dataframe/gettingstartedgradleadvanced.html) if you don't need some of the formats as dependencies,
51+
for Groovy and configurations specific for Android project
8652

87-
dependencies {
88-
implementation 'org.jetbrains.kotlinx:dataframe:0.12.0'
89-
}
53+
## Getting started
9054

91-
android {
92-
defaultConfig {
93-
minSdk 26 // Android O+
94-
}
95-
compileOptions {
96-
sourceCompatibility JavaVersion.VERSION_1_8
97-
targetCompatibility JavaVersion.VERSION_1_8
98-
}
99-
kotlinOptions {
100-
jvmTarget = '1.8'
101-
}
102-
packagingOptions {
103-
resources {
104-
pickFirsts = ["META-INF/AL2.0",
105-
"META-INF/LGPL2.1",
106-
"META-INF/ASL-2.0.txt",
107-
"META-INF/LICENSE.md",
108-
"META-INF/NOTICE.md",
109-
"META-INF/LGPL-3.0.txt"]
110-
excludes = ["META-INF/kotlin-jupyter-libraries/libraries.json",
111-
"META-INF/{INDEX.LIST,DEPENDENCIES}",
112-
"{draftv3,draftv4}/schema",
113-
"arrow-git.properties"]
114-
}
115-
}
116-
}
117-
118-
// optional, could be required for KSP
119-
tasks.withType(KotlinCompile).configureEach {
120-
kotlinOptions {
121-
jvmTarget = '1.8'
122-
}
123-
}
55+
```kotlin
56+
import org.jetbrains.kotlinx.dataframe.*
57+
import org.jetbrains.kotlinx.dataframe.api.*
58+
import org.jetbrains.kotlinx.dataframe.io.*
12459
```
12560

12661
```kotlin
127-
// build.gradle.kts
62+
val df = DataFrame.read("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
63+
df["full_name"][0] // Indexing https://kotlin.github.io/dataframe/access.html
12864

129-
plugins {
130-
// Optional Gradle plugin for enhanced type safety and schema generation
131-
// https://kotlin.github.io/dataframe/gradle.html
132-
id("org.jetbrains.kotlinx.dataframe") version "0.12.0"
133-
}
65+
df.filter { "stargazers_count"<Int>() > 50 }.print()
66+
```
13467

135-
dependencies {
136-
implementation("org.jetbrains.kotlinx:dataframe:0.12.0")
137-
}
68+
## Getting started with data schema
13869

139-
android {
140-
defaultConfig {
141-
minSdk = 26 // Android O+
142-
}
143-
compileOptions {
144-
sourceCompatibility = JavaVersion.VERSION_1_8
145-
targetCompatibility = JavaVersion.VERSION_1_8
146-
}
147-
kotlinOptions {
148-
jvmTarget = "1.8"
149-
}
150-
packaging {
151-
resources {
152-
pickFirsts += listOf(
153-
"META-INF/AL2.0",
154-
"META-INF/LGPL2.1",
155-
"META-INF/ASL-2.0.txt",
156-
"META-INF/LICENSE.md",
157-
"META-INF/NOTICE.md",
158-
"META-INF/LGPL-3.0.txt",
159-
)
160-
excludes += listOf(
161-
"META-INF/kotlin-jupyter-libraries/libraries.json",
162-
"META-INF/{INDEX.LIST,DEPENDENCIES}",
163-
"{draftv3,draftv4}/schema",
164-
"arrow-git.properties",
165-
)
166-
}
167-
}
168-
}
70+
Requires Gradle plugin to work
71+
```kotlin
72+
id("org.jetbrains.kotlinx.dataframe") version "0.12.0"
73+
```
74+
75+
Plugin generates extension properties API for provided sample of data. Column names and their types become discoverable in completion.
16976

170-
// required for KSP
171-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
172-
kotlinOptions.jvmTarget = "1.8"
77+
```kotlin
78+
// Make sure to place file annotation above package directive
79+
@file:ImportDataSchema(
80+
"Repository",
81+
"https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv",
82+
)
83+
84+
package example
85+
86+
import org.jetbrains.kotlinx.dataframe.annotations.ImportDataSchema
87+
import org.jetbrains.kotlinx.dataframe.api.*
88+
89+
fun main() {
90+
// execute `assemble` to generate extension properties API
91+
val df = Repository.readCSV()
92+
df.fullName[0]
93+
94+
df.filter { stargazersCount > 50 }
17395
}
17496
```
17597

176-
### Jupyter Notebook
98+
## Getting started in Jupyter Notebook / Kotlin Notebook
17799

178100
Install [Kotlin kernel](https://github.com/Kotlin/kotlin-jupyter) for [Jupyter](https://jupyter.org/)
179101

@@ -186,14 +108,26 @@ or specific version:
186108
%use dataframe(<version>)
187109
```
188110

111+
```kotlin
112+
val df = DataFrame.read("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
113+
df // last expression in the cell is displayed
114+
```
115+
116+
When cell with variable declaration is executed, in the next cell `DataFrame` provides extension properties API based on data
117+
```kotlin
118+
df.filter { stargazers_count > 50 }
119+
```
120+
189121
## Data model
190122
* `DataFrame` is a list of columns with equal sizes and distinct names.
191123
* `DataColumn` is a named list of values. Can be one of three kinds:
192124
* `ValueColumn` — contains data
193125
* `ColumnGroup` — contains columns
194126
* `FrameColumn` — contains dataframes
195127

196-
## Usage example
128+
## Syntax example
129+
130+
Let us show you how data cleaning and aggregation pipeline could look like with DataFrame.
197131

198132
**Create:**
199133
```kotlin
@@ -269,7 +203,9 @@ clean
269203
}
270204
```
271205

272-
[Try it in **Datalore**](https://datalore.jetbrains.com/view/notebook/vq5j45KWkYiSQnACA2Ymij) and explore [**more examples here**](examples).
206+
Check it on [**Datalore**](https://datalore.jetbrains.com/view/notebook/vq5j45KWkYiSQnACA2Ymij) to get better visual impression of what happens and how hierarchical DataFrame structure looks like.
207+
208+
Explore [**more examples here**](examples).
273209

274210
## Kotlin, Kotlin Jupyter, OpenAPI, Arrow and JDK versions
275211

docs/StardustDocs/topics/gettingStartedJupyterNotebook.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ If you want to use a specific version of the Kotlin DataFrame library, you can s
3333
```
3434

3535
After loading, all essential types will be already imported, so you can start using the Kotlin DataFrame library. Enjoy!
36+
37+
```kotlin
38+
val df = DataFrame.read("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
39+
df // last expression in the cell is displayed
40+
```
41+
42+
When previous cell with variable declaration is executed, `DataFrame` provides data schema API based on data:
43+
```kotlin
44+
df.filter { stargazers_count > 50 }
45+
```

0 commit comments

Comments
 (0)