Skip to content

Commit c0603bb

Browse files
Merge pull request #1251 from Kotlin/readme_update
Readme update
2 parents d8012ed + 33ff8a5 commit c0603bb

File tree

2 files changed

+2215
-16
lines changed

2 files changed

+2215
-16
lines changed

README.md

Lines changed: 104 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,26 @@ Kotlin DataFrame aims to reconcile Kotlin's static typing with the dynamic natur
2020
* **Typesafe** — on-the-fly generation of extension properties for type safe data access with Kotlin-style care for null safety.
2121
* **Polymorphic** — type compatibility derives from column schema compatibility. You can define a function that requires a special subset of columns in a dataframe but doesn't care about other columns.
2222

23-
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/)
23+
Integrates with [Kotlin Notebook](https://kotlinlang.org/docs/kotlin-notebook-overview.html).
24+
Inspired by [krangl](https://github.com/holgerbrandl/krangl), Kotlin Collections and [pandas](https://pandas.pydata.org/)
25+
26+
## 🚀 Quickstart
27+
28+
Looking for a fast and simple way to learn the basics?
29+
Get started in minutes with our [Quickstart Guide](https://kotlin.github.io/dataframe/quickstart.html).
30+
31+
It walks you through the core features of Kotlin DataFrame with minimal setup and clear examples
32+
— perfect for getting up to speed in just a few minutes.
33+
34+
[![quickstart_preview](docs/StardustDocs/images/guides/quickstart_preview.png)](https://kotlin.github.io/dataframe/quickstart.html)
2435

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)
@@ -46,31 +58,102 @@ Check out this [notebook with new features](examples/notebooks/feature_overviews
4658

4759
## Setup
4860

49-
```kotlin
50-
implementation("org.jetbrains.kotlinx:dataframe:1.0.0-Beta2")
61+
> For more detailed instructions on how to get started with Kotlin DataFrame, refer to the
62+
> [Getting Started](https://kotlin.github.io/dataframe/gettingstarted.html).
63+
64+
### Kotlin Notebook
65+
66+
You can use Kotlin DataFrame in [Kotlin Notebook](https://kotlinlang.org/docs/kotlin-notebook-overview.html),
67+
or other interactive environment with [Kotlin Jupyter Kernel](https://github.com/Kotlin/kotlin-jupyter) support,
68+
such as [Datalore](https://datalore.jetbrains.com/),
69+
and [Jupyter Notebook](https://jupyter.org/).
70+
71+
You can include all the necessary dependencies and imports in the notebook using *line magic*:
72+
73+
```
74+
%use dataframe
5175
```
5276

53-
Check out the [custom setup page](https://kotlin.github.io/dataframe/gettingstartedgradleadvanced.html) if you don't need some of the formats as dependencies,
54-
for Groovy, and for configurations specific to Android projects.
77+
You can use `%useLatestDescriptors`
78+
to get the latest stable version without updating the Kotlin kernel:
5579

56-
## Code example
80+
```
81+
%useLatestDescriptors
82+
%use dataframe
83+
```
5784

58-
```kotlin
59-
import org.jetbrains.kotlinx.dataframe.*
60-
import org.jetbrains.kotlinx.dataframe.api.*
61-
import org.jetbrains.kotlinx.dataframe.io.*
85+
Or manually specify the version:
86+
87+
```
88+
%use dataframe($dataframe_version)
6289
```
6390

91+
Refer to the
92+
[Get started with Kotlin DataFrame in Kotlin Notebook](https://kotlin.github.io/dataframe/gettingstartedkotlinnotebook.html)
93+
for details.
94+
95+
### Gradle
96+
97+
Add dependencies in the build.gradle.kts script:
98+
6499
```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
100+
dependencies {
101+
implementation("org.jetbrains.kotlinx:dataframe:1.0.0-Beta2")
102+
}
103+
```
104+
105+
Make sure that you have `mavenCentral()` in the list of repositories:
67106

68-
df.filter { "stargazers_count"<Int>() > 50 }.print()
107+
```kotlin
108+
repositories {
109+
mavenCentral()
110+
}
69111
```
70112

71-
## Getting started in Kotlin Notebook
113+
Refer to the
114+
[Get started with Kotlin DataFrame on Gradle](https://kotlin.github.io/dataframe/gettingstartedgradle.html)
115+
for details.
116+
Also, check out the [custom setup page](https://kotlin.github.io/dataframe/gettingstartedgradleadvanced.html)
117+
if you don't need some formats as dependencies,
118+
for Groovy, and for configurations specific to Android projects.
119+
120+
## Code example
72121

73-
Follow this [guide](https://kotlin.github.io/dataframe/gettingstartedkotlinnotebook.html)
122+
This example of Kotlin DataFrame code with
123+
the [Compiler Plugin](https://kotlin.github.io/dataframe/compiler-plugin.html) enabled.
124+
See [the full project](https://github.com/Kotlin/dataframe/tree/master/examples/kotlin-dataframe-plugin-example).
125+
See also
126+
[this example in Kotlin Notebook](https://github.com/Kotlin/dataframe/tree/master/examples/notebooks/readme_example.ipynb).
127+
128+
```kotlin
129+
val df = DataFrame
130+
// Read DataFrame from the CSV file.
131+
.readCsv("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
132+
// And convert it to match the `Repositories` schema.
133+
.convertTo<Repositories>()
134+
135+
// Update the DataFrame.
136+
val reposUpdated = repos
137+
// Rename columns to CamelCase.
138+
.renameToCamelCase()
139+
// Rename "stargazersCount" column to "stars".
140+
.rename { stargazersCount }.into("stars")
141+
// Filter by the number of stars:
142+
.filter { stars > 50 }
143+
// Convert values in the "topic" column (which were `String` initially)
144+
// to the list of topics.
145+
.convert { topics }.with {
146+
val inner = it.removeSurrounding("[", "]")
147+
if (inner.isEmpty()) emptyList() else inner.split(',').map(String::trim)
148+
}
149+
// Add a new column with the number of topics.
150+
.add("topicCount") { topics.size }
151+
152+
// Write the updated DataFrame to a CSV file.
153+
reposUpdated.writeCsv("jetbrains_repositories_new.csv")
154+
```
155+
156+
Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html).
74157

75158
## Data model
76159
* `DataFrame` is a list of columns with equal sizes and distinct names.
@@ -79,7 +162,12 @@ Follow this [guide](https://kotlin.github.io/dataframe/gettingstartedkotlinnoteb
79162
* `ColumnGroup` — contains columns
80163
* `FrameColumn` — contains dataframes
81164

82-
Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html).
165+
## Visualizations
166+
167+
[Kandy](https://kotlin.github.io/kandy/welcome.html) plotting library provides seamless visualizations
168+
for your dataframes.
169+
170+
![kandy_preview](docs/StardustDocs/images/guides/kandy_gallery_preview.png)
83171

84172
## Kotlin, Kotlin Jupyter, Arrow, and JDK versions
85173

0 commit comments

Comments
 (0)