Skip to content

Commit 858157b

Browse files
readme example
1 parent 43f3bbe commit 858157b

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

README.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@ Kotlin DataFrame aims to reconcile Kotlin's static typing with the dynamic natur
2222

2323
Integrates with [Kotlin kernel for Jupyter](https://github.com/Kotlin/kotlin-jupyter). Inspired by [krangl](https://github.com/holgerbrandl/krangl), Kotlin Collections and [pandas](https://pandas.pydata.org/)
2424

25+
## 🚀 Quickstart
26+
27+
Looking for a fast and simple way to learn the basics?
28+
Get started in minutes with our [Quickstart Guide](https://kotlin.github.io/dataframe/quickstart.html).
29+
30+
It walks you through the core features of Kotlin DataFrame with minimal setup and clear examples
31+
— perfect for getting up to speed in just a few minutes.
32+
33+
![quickstart_preview](docs/StardustDocs/images/guides/quickstart_preview.png)
34+
35+
2536
## Documentation
2637

2738
Explore [**documentation**](https://kotlin.github.io/dataframe) for details.
2839

2940
You could find the following articles there:
3041

42+
* [Guides and Examples](https://kotlin.github.io/dataframe/guides-and-examples.html)
3143
* [Get started with Kotlin DataFrame](https://kotlin.github.io/dataframe/gettingstarted.html)
3244
* [Working with Data Schemas](https://kotlin.github.io/dataframe/schemas.html)
3345
* [Setup compiler plugin in Gradle project](https://kotlin.github.io/dataframe/compiler-plugin.html)
@@ -56,21 +68,39 @@ for Groovy, and for configurations specific to Android projects.
5668
## Code example
5769

5870
```kotlin
59-
import org.jetbrains.kotlinx.dataframe.*
60-
import org.jetbrains.kotlinx.dataframe.api.*
61-
import org.jetbrains.kotlinx.dataframe.io.*
71+
val df = DataFrame
72+
// Read DataFrame from the CSV file.
73+
.readCsv("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
74+
// And convert it to match the `Repositories` schema.
75+
.convertTo<Repositories>()
76+
77+
// Let's update the DataFrame with some operations using these features.
78+
val reposUpdated = repos
79+
// Rename columns to CamelCase.
80+
// Note that after that, in the following operations, extension properties will have
81+
// new names corresponding to the column names.
82+
.renameToCamelCase()
83+
// Rename "stargazersCount" column to "stars".
84+
.rename { stargazersCount }.into("stars")
85+
// And we can immediately use the updated name in the filtering.
86+
.filter { stars > 50 }
87+
// Convert values in the "topic" column (which were `String` initially)
88+
// to the list of topics.
89+
.convert { topics }.with {
90+
val inner = it.removeSurrounding("[", "]")
91+
if (inner.isEmpty()) emptyList() else inner.split(',').map(String::trim)
92+
}
93+
// Now "topics" is a `List<String>` column.
94+
// Add a new column with the number of topics.
95+
.add("topicCount") { topics.size }
96+
// Add a new column with the kind of repository.
97+
.add("kind") { getKind(fullName, topics) }
98+
99+
// Write the updated DataFrame to a CSV file.
100+
reposUpdated.writeCsv("jetbrains_repositories_new.csv")
62101
```
63102

64-
```kotlin
65-
val df = DataFrame.read("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
66-
df["full_name"][0] // Indexing https://kotlin.github.io/dataframe/access.html
67-
68-
df.filter { "stargazers_count"<Int>() > 50 }.print()
69-
```
70-
71-
## Getting started in Kotlin Notebook
72-
73-
Follow this [guide](https://kotlin.github.io/dataframe/gettingstartedkotlinnotebook.html)
103+
Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html).
74104

75105
## Data model
76106
* `DataFrame` is a list of columns with equal sizes and distinct names.
@@ -79,8 +109,6 @@ Follow this [guide](https://kotlin.github.io/dataframe/gettingstartedkotlinnoteb
79109
* `ColumnGroup` — contains columns
80110
* `FrameColumn` — contains dataframes
81111

82-
Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html).
83-
84112
## Kotlin, Kotlin Jupyter, Arrow, and JDK versions
85113

86114
This table shows the mapping between main library component versions and minimum supported Java versions.

0 commit comments

Comments
 (0)