Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
koperagen committed Jan 17, 2025
1 parent 6d84005 commit 6035209
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ dependencies {
implementation(libs.serialization.core)
implementation(libs.serialization.json)
implementation(libs.fastDoubleParser)
implementation("org.jetbrains:annotations:23.0.0")

api(libs.kotlin.datetimeJvm)
implementation(libs.kotlinpoet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import kotlin.reflect.KType
* @param T Schema marker. It identifies column schema and is used to generate schema-specific extension properties for typed data access. It is covariant, so `DataFrame<A>` is assignable to variable of type `DataFrame<B>` if `A` is a subtype of `B`.
*/
@HasSchema(schemaArg = 0)
@org.jetbrains.annotations.Debug.Renderer(
text = "\"DataFrame \" + org.jetbrains.kotlinx.dataframe.DataFrameKt.size(this)",
childrenArray = "this.columns1().toArray()",
)
public interface DataFrame<out T> :
Aggregatable<T>,
ColumnsContainer<T> {
Expand Down Expand Up @@ -69,6 +73,8 @@ public interface DataFrame<out T> :

public operator fun iterator(): Iterator<DataRow<T>> = rows().iterator()

public fun rowsList(): List<DataRow<T>> = rows().toList()

// endregion

public fun <R> aggregate(body: AggregateGroupedBody<T, R>): DataRow<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlin.reflect.KProperty
*
* @param T Schema marker. See [DataFrame] for details
*/
@org.jetbrains.annotations.Debug.Renderer(childrenArray = "this.values().toArray()")
public interface DataRow<out T> {

public fun index(): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import kotlin.reflect.KProperty
* @param T Schema marker. See [DataFrame] for details.
*/
@HasSchema(schemaArg = 0)
@org.jetbrains.annotations.Debug.Renderer(text = "\" ColumnGroup \"")
public interface ColumnGroup<out T> :
BaseColumn<DataRow<T>>,
DataFrame<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.jetbrains.kotlinx.dataframe.columns

import org.jetbrains.kotlinx.dataframe.DataColumn
import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
import org.jetbrains.kotlinx.dataframe.api.group
import org.jetbrains.kotlinx.dataframe.api.into
import org.jetbrains.kotlinx.dataframe.api.print
import org.jetbrains.kotlinx.dataframe.size
import kotlin.reflect.KProperty

/**
Expand All @@ -10,6 +15,10 @@ import kotlin.reflect.KProperty
*
* @param T - type of values
*/
@org.jetbrains.annotations.Debug.Renderer(
text = "this.name() + \": \" + org.jetbrains.kotlinx.dataframe.impl.RenderingKt.renderType(this)",
childrenArray = "this.toList().toArray()",
)
public interface ValueColumn<out T> : DataColumn<T> {

override fun kind(): ColumnKind = ColumnKind.Value
Expand All @@ -25,3 +34,9 @@ public interface ValueColumn<out T> : DataColumn<T> {

public override operator fun get(range: IntRange): ValueColumn<T>
}

internal fun main() {
val df = dataFrameOf("a", "b")(123, "aaa").group("a", "b").into("c")
df.size().toString()
df.print()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.jetbrains.kotlinx.dataframe.impl

import org.jetbrains.kotlinx.dataframe.AnyCol
import org.jetbrains.kotlinx.dataframe.AnyFrame
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.api.ValueCount
import org.jetbrains.kotlinx.dataframe.api.count
import org.jetbrains.kotlinx.dataframe.api.map
import org.jetbrains.kotlinx.dataframe.api.namedValues
import org.jetbrains.kotlinx.dataframe.size

public class Counts(public val value: Any?, public val count: Int) {
override fun toString(): String = "$value -> $count"
}

public fun nodeExpression(df: AnyFrame): String = "DataFrame ${df.size()}"

public class Info(public val df: AnyFrame)

public fun DataFrame<ValueCount>.render(): List<Counts> = map { Counts(it.get(0), it.count) }

@org.jetbrains.annotations.Debug.Renderer(childrenArray = "this.getColumn().toList().toArray()")
public class ValueColumnImplW(public val column: AnyCol) : List<Any?> by column.toList()

private fun f(v: DataRow<*>) {
v.namedValues()
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlin.reflect.KType

internal val anyRowType = createTypeWithArgument<AnyRow>()

@org.jetbrains.annotations.Debug.Renderer(text = "\" ColumnGroup \"")
internal open class ColumnGroupImpl<T>(private val name: String, df: DataFrame<T>) :
DataFrameImpl<T>(df.columns(), df.nrow),
DataColumnInternal<DataRow<T>>,
Expand Down

0 comments on commit 6035209

Please sign in to comment.