Skip to content

Commit bd178e3

Browse files
committed
Merge branch 'master' into parsing-optimization
# Conflicts: # core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt
2 parents de81ab6 + 976d4d7 commit bd178e3

File tree

31 files changed

+9325
-9583
lines changed

31 files changed

+9325
-9583
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
ALGOLIA_INDEX_NAME: prod_DATAFRAME_HELP
1818
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }}
1919
CONFIG_JSON_PRODUCT: Dataframe
20-
CONFIG_JSON_VERSION: '0.13'
20+
CONFIG_JSON_VERSION: '0.14'
2121

2222
jobs:
2323
build-job:

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Kotlin DataFrame: typesafe in-memory structured data processing for JVM
22
[![JetBrains incubator project](https://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
33
[![Kotlin component alpha stability](https://img.shields.io/badge/project-alpha-kotlin.svg?colorA=555555&colorB=DB3683&label=&logo=kotlin&logoColor=ffffff&logoWidth=10)](https://kotlinlang.org/docs/components-stability.html)
4-
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.22-blue.svg?logo=kotlin)](http://kotlinlang.org)
4+
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
55
[![Dynamic XML Badge](https://img.shields.io/badge/dynamic/xml?url=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Forg%2Fjetbrains%2Fkotlinx%2Fdataframe%2Fmaven-metadata.xml&query=%2F%2Fversion%5Bnot%28contains%28text%28%29%2C%22dev%22%29%29%5D%5Blast%28%29%5D&label=Release%20version)](https://search.maven.org/artifact/org.jetbrains.kotlinx/dataframe)
66
[![Dynamic XML Badge](https://img.shields.io/badge/dynamic/xml?url=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Forg%2Fjetbrains%2Fkotlinx%2Fdataframe%2Fmaven-metadata.xml&query=%2F%2Fversion%5Bcontains%28text%28%29%2C%22dev%22%29%5D%5Blast%28%29%5D&label=Dev%20version&color=yellow
77
)](https://search.maven.org/artifact/org.jetbrains.kotlinx/dataframe)
@@ -41,18 +41,18 @@ You could find the following articles there:
4141
Check out this [notebook with new features](examples/notebooks/feature_overviews/0.14.0/new_features.ipynb) in development for the next release.
4242

4343
The DataFrame compiler plugin has reached public preview!
44-
Here's a [compiler plugin demo project](https://github.com/koperagen/df-plugin-demo) that works with IntelliJ IDEA 2024.2.
44+
Here's a [compiler plugin demo project](https://github.com/koperagen/df-plugin-demo) that works with [IntelliJ IDEA](https://www.jetbrains.com/idea/) 2024.2.
4545

4646
## Setup
4747

4848
```kotlin
49-
implementation("org.jetbrains.kotlinx:dataframe:0.13.1")
49+
implementation("org.jetbrains.kotlinx:dataframe:0.14.0")
5050
```
5151

5252
Optional Gradle plugin for enhanced type safety and schema generation
5353
https://kotlin.github.io/dataframe/schemasgradle.html
5454
```kotlin
55-
id("org.jetbrains.kotlinx.dataframe") version "0.13.1"
55+
id("org.jetbrains.kotlinx.dataframe") version "0.14.0"
5656
```
5757

5858
Check out the [custom setup page](https://kotlin.github.io/dataframe/gettingstartedgradleadvanced.html) if you don't need some of the formats as dependencies,
@@ -77,7 +77,7 @@ df.filter { "stargazers_count"<Int>() > 50 }.print()
7777

7878
Requires Gradle plugin to work
7979
```kotlin
80-
id("org.jetbrains.kotlinx.dataframe") version "0.13.1"
80+
id("org.jetbrains.kotlinx.dataframe") version "0.14.0"
8181
```
8282

8383
Plugin generates extension properties API for provided sample of data. Column names and their types become discoverable in completion.
@@ -228,6 +228,7 @@ This table shows the mapping between main library component versions and minimum
228228
| 0.12.0 | 8 | 1.9.0 | 0.11.0-358 | 3.0.0 | 11.0.0 |
229229
| 0.12.1 | 8 | 1.9.0 | 0.11.0-358 | 3.0.0 | 11.0.0 |
230230
| 0.13.1 | 8 | 1.9.22 | 0.12.0-139 | 3.0.0 | 15.0.0 |
231+
| 0.14.0 | 8 | 2.0.20 | 0.12.0-139 | 3.0.0 | 17.0.0 |
231232

232233
## Code of Conduct
233234

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/groupBy.kt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
1111
import org.jetbrains.kotlinx.dataframe.annotations.Refine
1212
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
1313
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
14-
import org.jetbrains.kotlinx.dataframe.impl.GroupByImpl
1514
import org.jetbrains.kotlinx.dataframe.impl.aggregation.PivotImpl
1615
import org.jetbrains.kotlinx.dataframe.impl.api.getPivotColumnPaths
1716
import org.jetbrains.kotlinx.dataframe.impl.api.groupByImpl
@@ -85,24 +84,17 @@ public interface GroupBy<out T, out G> : Grouped<G> {
8584

8685
public fun filter(predicate: GroupedRowFilter<T, G>): GroupBy<T, G>
8786

87+
@Refine
88+
@Interpretable("GroupByToDataFrame")
89+
public fun toDataFrame(groupedColumnName: String? = null): DataFrame<T>
90+
8891
public data class Entry<T, G>(val key: DataRow<T>, val group: DataFrame<G>)
8992

9093
public companion object {
9194
internal val groupedColumnAccessor = column<AnyFrame>("group")
9295
}
9396
}
9497

95-
@Refine
96-
@Interpretable("GroupByToDataFrame")
97-
public fun <T, G> GroupBy<T, G>.toDataFrame(groupedColumnName: String? = null): DataFrame<T> =
98-
if (groupedColumnName == null || groupedColumnName == groups.name()) {
99-
internal().df
100-
} else {
101-
internal().df.rename(groups).into(groupedColumnName)
102-
}
103-
104-
internal fun <T, G> GroupBy<T, G>.internal(): GroupByImpl<T, G> = this as GroupByImpl<T, G>
105-
10698
public interface Grouped<out T> : Aggregatable<T>
10799

108100
public class ReducedGroupBy<T, G>(

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/GroupByImpl.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import org.jetbrains.kotlinx.dataframe.api.concat
1313
import org.jetbrains.kotlinx.dataframe.api.convert
1414
import org.jetbrains.kotlinx.dataframe.api.getColumn
1515
import org.jetbrains.kotlinx.dataframe.api.getColumnsWithPaths
16+
import org.jetbrains.kotlinx.dataframe.api.into
1617
import org.jetbrains.kotlinx.dataframe.api.isColumnGroup
1718
import org.jetbrains.kotlinx.dataframe.api.minus
1819
import org.jetbrains.kotlinx.dataframe.api.pathOf
20+
import org.jetbrains.kotlinx.dataframe.api.rename
1921
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
2022
import org.jetbrains.kotlinx.dataframe.impl.aggregation.AggregatableInternal
2123
import org.jetbrains.kotlinx.dataframe.impl.aggregation.GroupByReceiverImpl
@@ -56,6 +58,13 @@ internal class GroupByImpl<T, G>(
5658
}
5759
return df[indices].asGroupBy(groups)
5860
}
61+
62+
override fun toDataFrame(groupedColumnName: String?): DataFrame<T> =
63+
if (groupedColumnName == null || groupedColumnName == groups.name()) {
64+
df
65+
} else {
66+
df.rename(groups).into(groupedColumnName)
67+
}
5968
}
6069

6170
internal fun <T, G, R> aggregateGroupBy(

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroups.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ public interface ColGroupsColumnsSelectionDsl {
212212
@Suppress("UNCHECKED_CAST")
213213
internal fun ColumnsResolver<*>.columnGroupsInternal(
214214
filter: (ColumnGroup<*>) -> Boolean,
215-
): TransformableColumnSet<AnyRow> =
216-
colsInternal { it.isColumnGroup() && filter(it.asColumnGroup()) } as TransformableColumnSet<AnyRow>
215+
): TransformableColumnSet<AnyRow> = colsInternal { it.isColumnGroup() && filter(it) } as TransformableColumnSet<AnyRow>
217216

218217
// endregion

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/groupBy.kt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
1111
import org.jetbrains.kotlinx.dataframe.annotations.Refine
1212
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
1313
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
14-
import org.jetbrains.kotlinx.dataframe.impl.GroupByImpl
1514
import org.jetbrains.kotlinx.dataframe.impl.aggregation.PivotImpl
1615
import org.jetbrains.kotlinx.dataframe.impl.api.getPivotColumnPaths
1716
import org.jetbrains.kotlinx.dataframe.impl.api.groupByImpl
@@ -85,24 +84,17 @@ public interface GroupBy<out T, out G> : Grouped<G> {
8584

8685
public fun filter(predicate: GroupedRowFilter<T, G>): GroupBy<T, G>
8786

87+
@Refine
88+
@Interpretable("GroupByToDataFrame")
89+
public fun toDataFrame(groupedColumnName: String? = null): DataFrame<T>
90+
8891
public data class Entry<T, G>(val key: DataRow<T>, val group: DataFrame<G>)
8992

9093
public companion object {
9194
internal val groupedColumnAccessor = column<AnyFrame>("group")
9295
}
9396
}
9497

95-
@Refine
96-
@Interpretable("GroupByToDataFrame")
97-
public fun <T, G> GroupBy<T, G>.toDataFrame(groupedColumnName: String? = null): DataFrame<T> =
98-
if (groupedColumnName == null || groupedColumnName == groups.name()) {
99-
internal().df
100-
} else {
101-
internal().df.rename(groups).into(groupedColumnName)
102-
}
103-
104-
internal fun <T, G> GroupBy<T, G>.internal(): GroupByImpl<T, G> = this as GroupByImpl<T, G>
105-
10698
public interface Grouped<out T> : Aggregatable<T>
10799

108100
public class ReducedGroupBy<T, G>(

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public data class ParserOptions(
5858
public fun DataColumn<String?>.tryParse(options: ParserOptions? = null): DataColumn<*> = tryParseImpl(options)
5959

6060
public fun <T> DataFrame<T>.parse(options: ParserOptions? = null): DataFrame<T> =
61-
parseImpl(options) {
61+
parse(options) {
6262
colsAtAnyDepth { !it.isColumnGroup() }
6363
}
6464

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ internal fun <C, R> SingleColumn<DataRow<C>>.selectInternal(selector: ColumnsSel
252252
"Column ${col.path} is not a ColumnGroup and can thus not be selected from."
253253
}
254254

255-
col.asColumnGroup()
256-
.getColumnsWithPaths(selector as ColumnsSelector<*, R>)
255+
col.getColumnsWithPaths(selector as ColumnsSelector<*, R>)
257256
.map { it.changePath(col.path + it.path) }
258257
} ?: emptyList()
259258
}

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ public interface ValueColsColumnsSelectionDsl {
179179
* @return A [TransformableColumnSet] containing the value columns that satisfy the filter.
180180
*/
181181
internal fun ColumnsResolver<*>.valueColumnsInternal(filter: (ValueColumn<*>) -> Boolean): TransformableColumnSet<*> =
182-
colsInternal { it.isValueColumn() && filter(it.asValueColumn()) }
182+
colsInternal { it.isValueColumn() && filter(it) }
183183

184184
// endregion

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/DataFrameReceiver.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.jetbrains.kotlinx.dataframe.ColumnSelector
44
import org.jetbrains.kotlinx.dataframe.DataColumn
55
import org.jetbrains.kotlinx.dataframe.DataFrame
66
import org.jetbrains.kotlinx.dataframe.DataRow
7-
import org.jetbrains.kotlinx.dataframe.api.asColumnGroup
87
import org.jetbrains.kotlinx.dataframe.api.asDataColumn
98
import org.jetbrains.kotlinx.dataframe.api.cast
109
import org.jetbrains.kotlinx.dataframe.api.isColumnGroup
@@ -78,7 +77,9 @@ internal open class DataFrameReceiver<T>(
7877
DataColumn.createColumnGroup("", df).addPath(emptyPath())
7978

8079
override fun columns() =
81-
df.columns().map { if (it.isColumnGroup()) ColumnGroupWithParent(null, it.asColumnGroup()) else it }
80+
df.columns().map {
81+
if (it.isColumnGroup()) ColumnGroupWithParent(null, it) else it
82+
}
8283

8384
override fun columnNames() = df.columnNames()
8485

0 commit comments

Comments
 (0)