|
2 | 2 |
|
3 | 3 | The Kotlin DataFrame library gives you the power to manipulate data in your Kotlin projects.
|
4 | 4 |
|
5 |
| -This page explains how to: |
6 |
| -* Set up the Kotlin DataFrame library in an IntelliJ IDEA project with Gradle. |
7 |
| -* Import and manipulate data. |
8 |
| -* Export data. |
9 |
| - |
10 |
| -To use the Kotlin DataFrame library with Jupyter notebooks or Datalore, follow the instructions on our [Installation page](installation.md). |
| 5 | +To use the Kotlin DataFrame library with a [custom Gradle configuration](gettingStartedGradle.md), |
| 6 | +[Jupyter Notebooks](gettingStartedJupyterNotebook.md), or [Datalore](gettingStartedJupyterNotebook.md), |
| 7 | +follow the instructions on the appropriate pages. |
11 | 8 |
|
12 | 9 | ## Install Kotlin
|
13 | 10 |
|
14 | 11 | Kotlin is included in each IntelliJ IDEA release.
|
15 | 12 | Download and install [IntelliJ IDEA](https://www.jetbrains.com/idea/download/) to start using Kotlin.
|
16 | 13 |
|
17 |
| -## Create Kotlin project |
18 |
| - |
19 |
| -1. In IntelliJ IDEA, select **File** | **New** | **Project**. |
20 |
| -2. In the panel on the left, select **New Project**. |
21 |
| -3. Name the new project and change its location, if necessary. |
22 |
| - |
23 |
| - > Select the **Create Git repository** checkbox to place the new project under version control. You can enable this |
24 |
| - > later at any time. |
25 |
| - > |
26 |
| - {type="tip"} |
27 |
| - |
28 |
| -4. From the **Language** list, select **Kotlin**. |
29 |
| -5. Select the **Gradle** build system. |
30 |
| -6. From the **JDK list**, select the [JDK](https://www.oracle.com/java/technologies/downloads/) that you want to use in |
31 |
| - your project. The minimum supported version is JDK 8. |
32 |
| - * If the JDK is installed on your computer, but not defined in the IDE, select **Add JDK** and specify the path to the |
33 |
| - JDK home directory. |
34 |
| - * If you don't have the necessary JDK on your computer, select **Download JDK**. |
35 |
| -7. From the **Gradle DSL** list, select **Kotlin** or **Groovy**. |
36 |
| -8. Select the **Add sample code** checkbox to create a file with a sample `"Hello World!"` application. |
37 |
| -9. Click **Create**. |
38 |
| - |
39 |
| -You have successfully created a project with Gradle. |
40 |
| - |
41 |
| -### Update Gradle dependencies |
42 |
| - |
43 |
| -In your Gradle build file (`build.gradle.kts`), add the Kotlin DataFrame library as a dependency: |
44 | 14 |
|
| 15 | +## Create your powerful application with the Kotlin DataFrame library |
45 | 16 | <tabs>
|
46 |
| -<tab title="Kotlin DSL"> |
47 |
| - |
48 |
| -```kotlin |
49 |
| -dependencies { |
50 |
| - implementation("org.jetbrains.kotlinx:dataframe:%dataFrameVersion%") |
51 |
| -} |
52 |
| -``` |
53 |
| - |
| 17 | +<tab title="Gradle"> |
| 18 | +Here is how you can take the first steps in developing data-intensive Kotlin applications with Gradle in IntelliJ IDEA. |
| 19 | + |
| 20 | +1. **Create your first application for data exploration:** |
| 21 | + * To start from scratch, |
| 22 | + create a [basic JVM application with the IntelliJ IDEA project wizard](gettingStartedGradle.md). |
| 23 | + * To set up the custom Gradle configuration or Linter configuration, follow the instruction on this [page](gettingStartedGradleAdvanced.md). |
| 24 | + * If you prefer more robust examples, try to use Kotlin DataFrame together with KotlinDL, |
| 25 | + like in the [Titanic example](https://github.com/Kotlin/dataframe/tree/master/examples/idea-examples/titanic). |
| 26 | +2. **Use Kotlin DataFrame and third-party Kotlin Data Science libraries in your application:** |
| 27 | + * You can find a curated list of recommended data science libraries on the JVM [here](https://kotlinlang.org/docs/data-science-overview.html#java-libraries). |
| 28 | +3. **Learn more about Kotlin DataFrame usage:** |
| 29 | + * [Kotlin DataFrame Preview blogpost](https://blog.jetbrains.com/kotlin/2022/06/kotlin-dataframe-library-preview/) |
| 30 | + * [Kotlin DataFrame Overview (video)](https://www.youtube.com/watch?v=qGou8F2asNw) |
| 31 | + * [Replacing SQL with Kotlin's 'dataframe' on the Las Vegas Strip by Andrew Goldberg (video)](https://www.youtube.com/watch?v=sDZWiu9nnuU) |
| 32 | + * [How to use KotlinDL, Kotlin DataFrame library and Kandy together (video)](https://www.youtube.com/watch?v=4IYBVdyP_8s) |
| 33 | +4. **Join the Kotlin Data Science community:** |
| 34 | + * Slack: |
| 35 | + get an [invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up?_ga=2.148899126.1808346675.1686912551-1605045648.1686912543&_gl=1*64xzk9*_ga*MTYwNTA0NTY0OC4xNjg2OTEyNTQz*_ga_9J976DJZ68*MTY4NjkxMjU0Mi4xLjEuMTY4NjkxNTE3OC41OC4wLjA.) |
| 36 | + and join the #datascience, #science, #mathematics channels. |
| 37 | + * StackOverflow: |
| 38 | + subscribe to the ["kotlin"](https://stackoverflow.com/questions/tagged/kotlin) |
| 39 | + and ["kotlin-dataframe"](https://stackoverflow.com/questions/tagged/kotlin-dataframe) tags. |
| 40 | +5. **Follow Kotlin for Data Science** on [Twitter](https://twitter.com/KotlinForData) |
| 41 | + |
| 42 | +If you encounter any difficulties or problems, |
| 43 | +report an issue to our [issue tracker](https://github.com/Kotlin/dataframe/issues). |
54 | 44 | </tab>
|
55 | 45 |
|
56 |
| -<tab title="Groovy DSL"> |
| 46 | +<tab title="Jupyter Notebook"> |
| 47 | +Support for programming in Jupyter Notebook is one of Kotlin's key benefits. |
| 48 | +It brings new visualization and presentation possibilities |
| 49 | +while retaining the power and benefits of a strongly typed programming language. |
| 50 | + |
| 51 | +1. **[Set up your environment for development in Jupyter Notebook.](https://jupyter.org/install)** |
| 52 | +2. **Create your first notebook running with the Kotlin kernel:** |
| 53 | + * To start from scratch, create a [basic Kotlin notebook](gettingStartedJupyterNotebook.md). |
| 54 | + * If you prefer more robust examples, you can download and run [these examples](https://github.com/Kotlin/dataframe/tree/master/examples/notebooks) locally. |
| 55 | +3. **[Learn more about Kotlin kernel for Jupyter Notebook.](https://github.com/Kotlin/kotlin-jupyter)** |
| 56 | +4. **Join the Kotlin Data Science community:** |
| 57 | + * Slack: |
| 58 | + get an [invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up?_ga=2.148899126.1808346675.1686912551-1605045648.1686912543&_gl=1*64xzk9*_ga*MTYwNTA0NTY0OC4xNjg2OTEyNTQz*_ga_9J976DJZ68*MTY4NjkxMjU0Mi4xLjEuMTY4NjkxNTE3OC41OC4wLjA.) |
| 59 | + and join the #datascience, #science, #mathematics channels. |
| 60 | + * StackOverflow: |
| 61 | + subscribe to the ["kotlin"](https://stackoverflow.com/questions/tagged/kotlin) |
| 62 | + and ["kotlin-dataframe"](https://stackoverflow.com/questions/tagged/kotlin-dataframe) tags. |
| 63 | +5. **Follow Kotlin for Data Science** on [Twitter](https://twitter.com/KotlinForData) |
| 64 | +</tab> |
57 | 65 |
|
58 |
| -```kotlin |
59 |
| -dependencies { |
60 |
| - implementation 'org.jetbrains.kotlinx:dataframe:%dataFrameVersion%' |
61 |
| -} |
62 |
| -``` |
| 66 | +<tab title="Datalore"> |
| 67 | +With Datalore, you can use Kotlin in the browser straight out of the box, no installation required. |
| 68 | + |
| 69 | +You can also collaborate on Kotlin notebooks in real time, |
| 70 | +get smart coding assistance when writing code, and share results as interactive or static reports. |
| 71 | + |
| 72 | +1. **[Create your first notebook in Datalore](https://www.jetbrains.com/datalore/features/notebooks/)** |
| 73 | + * To start from scratch, create a [basic Kotlin notebook](gettingStartedDatalore.md). |
| 74 | + * If you prefer more robust examples, you can download them from GitHub, upload them to Datalore, |
| 75 | + and run [these examples](https://github.com/Kotlin/dataframe/tree/master/examples/notebooks) here. |
| 76 | +2. **[Learn more about Kotlin kernel for Jupyter Notebook.](https://github.com/Kotlin/kotlin-jupyter)** |
| 77 | +3. **Join the Kotlin Data Science community:** |
| 78 | + * Slack: |
| 79 | + get an [invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up?_ga=2.148899126.1808346675.1686912551-1605045648.1686912543&_gl=1*64xzk9*_ga*MTYwNTA0NTY0OC4xNjg2OTEyNTQz*_ga_9J976DJZ68*MTY4NjkxMjU0Mi4xLjEuMTY4NjkxNTE3OC41OC4wLjA.) |
| 80 | + and join the #datascience, #science, #mathematics channels. |
| 81 | + * StackOverflow: |
| 82 | + subscribe to the ["kotlin"](https://stackoverflow.com/questions/tagged/kotlin) |
| 83 | + and ["kotlin-dataframe"](https://stackoverflow.com/questions/tagged/kotlin-dataframe) tags. |
| 84 | +4. **Follow Kotlin for Data Science** on [Twitter](https://twitter.com/KotlinForData) |
63 | 85 |
|
64 | 86 | </tab>
|
65 |
| - |
66 | 87 | </tabs>
|
67 |
| - |
68 |
| -### Add imports |
69 |
| - |
70 |
| -In `src/main/kotlin/Main.kt`, add the following imports at the top of the file: |
71 |
| - |
72 |
| -```kotlin |
73 |
| -import org.jetbrains.kotlinx.dataframe.DataFrame |
74 |
| -import org.jetbrains.kotlinx.dataframe.io.* |
75 |
| -import org.jetbrains.kotlinx.dataframe.api.* |
76 |
| -``` |
77 |
| - |
78 |
| -## Import data |
79 |
| - |
80 |
| -Download the file `movies.csv` from [here](https://github.com/Kotlin/dataframe/blob/master/data/movies.csv) to the root directory of your project: |
81 |
| - |
82 |
| - |
83 |
| -Delete the `println()` functions and comments from your main function in `Main.kt`. |
84 |
| - |
85 |
| -To import the movie sample data into a data frame and print it, inside your main function in `Main.kt`, add the following code: |
86 |
| - |
87 |
| -```kotlin |
88 |
| - // Import your data to a data frame |
89 |
| - var df = DataFrame.read("movies.csv") |
90 |
| - |
91 |
| - // Print your data frame |
92 |
| - df.print() |
93 |
| -``` |
94 |
| - |
95 |
| -## Manipulate data |
96 |
| - |
97 |
| -To print some information about your data frame and sort your data, add the following additional lines of code: |
98 |
| - |
99 |
| -```kotlin |
100 |
| - // Print some information about the data frame |
101 |
| - println(df.columnNames()) // Print column names |
102 |
| - println(df.count()) // Print number of rows |
103 |
| - |
104 |
| - // Sort your data alphabetically by title |
105 |
| - df = df.sortBy("title") |
106 |
| - |
107 |
| - // Filter your data so that only comedy films remain, and print |
108 |
| - df = df.filter { "genres"<String>().contains("Comedy") } |
109 |
| - df.print() |
110 |
| -``` |
111 |
| - |
112 |
| -## Export data |
113 |
| - |
114 |
| -To export the current version of your data frame in CSV format, add the following additional lines of code and run `Main.kt`. |
115 |
| - |
116 |
| -```kotlin |
117 |
| - // Export your manipulated data to CSV format |
118 |
| - df.writeCSV("movies-by-title.csv") |
119 |
| -``` |
120 |
| - |
121 |
| - |
122 |
| -<code-block lang="console" collapsed-title="Example terminal output" collapsible="true"> |
123 |
| - movieId title genres |
124 |
| - 0 9b30aff7943f44579e92c261f3adc193 Women in Black (1997) Fantasy|Suspenseful|Comedy |
125 |
| - 1 2a1ba1fc5caf492a80188e032995843e Bumblebee Movie (2007) Comedy|Jazz|Family|Animation |
126 |
| - 2 f44ceb4771504342bb856d76c112d5a6 Magical School Boy and the Rock of Wi... Fantasy|Growing up|Magic |
127 |
| - 3 43d02fb064514ff3bd30d1e3a7398357 Master of the Jewlery: The Company of... Fantasy|Magic|Suspenseful |
128 |
| - 4 6aa0d26a483148998c250b9c80ddf550 Sun Conflicts: Part IV: A Novel Espai... Fantasy |
129 |
| - 5 eace16e59ce24eff90bf8924eb6a926c The Outstanding Bulk (2008) Fantasy|Superhero|Family |
130 |
| - 6 ae916bc4844a4bb7b42b70d9573d05cd In Automata (2014) Horror|Existential |
131 |
| - 7 c1f0a868aeb44c5ea8d154ec3ca295ac Interplanetary (2014) Sci-fi|Futuristic |
132 |
| - 8 9595b771f87f42a3b8dd07d91e7cb328 Woods Run (1994) Family|Drama |
133 |
| - 9 aa9fc400e068443488b259ea0802a975 Anthropod-Dude (2002) Superhero|Fantasy|Family|Growing up |
134 |
| - 10 22d20c2ba11d44cab83aceea39dc00bd The Chamber (2003) Comedy|Drama |
135 |
| - 11 8cf4d0c1bd7b41fab6af9d92c892141f That Thing About an Iceberg (1997) Drama|History|Family|Romance |
136 |
| - 12 c2f3e7588da84684a7d78d6bd8d8e1f4 Vehicles (2006) Animation|Family |
137 |
| - 13 ce06175106af4105945f245161eac3c7 Playthings Tale (1995) Animation|Family |
138 |
| - 14 ee28d7e69103485c83e10b8055ef15fb Metal Man 2 (2010) Fantasy|Superhero|Family |
139 |
| - 15 c32bdeed466f4ec09de828bb4b6fc649 Surgeon Odd in the Omniverse of Crazy... Fantasy|Superhero|Family|Horror |
140 |
| - 16 d4a325ab648a42c4a2d6f35dfabb387f Bad Dream on Pine Street (1984) Horror |
141 |
| - 17 60ebe74947234ddcab49dea1a958faed The Shimmering (1980) Horror |
142 |
| - 18 f24327f2b05147b197ca34bf13ae3524 Krubit: Societal Teachings for Do Man... Comedy |
143 |
| - 19 2bb29b3a245e434fa80542e711fd2cee This is No Movie (1950) (no genres listed) |
144 |
| -[movieId, title, genres] |
145 |
| -20 |
146 |
| -movieId title genres |
147 |
| -0 2a1ba1fc5caf492a80188e032995843e Bumblebee Movie (2007) Comedy|Jazz|Family|Animation |
148 |
| -1 f24327f2b05147b197ca34bf13ae3524 Krubit: Societal Teachings for Do Man... Comedy |
149 |
| -2 22d20c2ba11d44cab83aceea39dc00bd The Chamber (2003) Comedy|Drama |
150 |
| -3 9b30aff7943f44579e92c261f3adc193 Women in Black (1997) Fantasy|Suspenseful|Comedy |
151 |
| -</code-block> |
152 |
| - |
153 |
| -Congratulations! You have successfully used the Kotlin DataFrame library to import, manipulate and export data. |
154 |
| - |
155 |
| -## Next steps |
156 |
| -* Learn more about how to [import and export data](io.md) |
157 |
| -* Learn about our different [access APIs](apiLevels.md) |
158 |
| -* Explore the many different [operations that you can perform](operations.md) |
0 commit comments