`implode` on a `FrameColumn` gives inconsistent results

Abierto
#2,185 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
kotlin
Área
data

Línea de trabajo

Start by reading implodeImpl, especially the ColumnKind.Frame branch mentioned in the issue, and compare its value construction with the resulting column type. Reproduce the single-group example, then check the multi-group case to see how each cell behaves. Done when implode returns values consistent with the declared type and both examples can be accessed without a ClassCastException.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Description
val df = dataFrameOf("key", "frames")(
    1, dataFrameOf("x")(1),
    1, dataFrameOf("x")(2),
)

val result = df.implode("frames")

println(result.frames.kind) // ValueColumn
println(result.frames.type()) // kotlin.collections.List<org.jetbrains.kotlinx.dataframe.DataFrame<*>>

frames is a FrameColumn. After implode it becomes a ValueColumn with type List<DataFrame<*>>, but the cell contains a DataFrame (both frames concatenated), not a List.

println(result.frames)
                 frames
     List<DataFrame<*>>
                   ----
  0             [2 x 1]

An attempt access a value (list of dataframes) of this column throws:

val first = result.frames[0]
Exception in thread "main" java.lang.ClassCastException: class org.jetbrains.kotlinx.dataframe.impl.DataFrameImpl cannot be cast to class java.util.List (org.jetbrains.kotlinx.dataframe.impl.DataFrameImpl is in unnamed module of loader 'app'; java.util.List is in module java.base of loader 'bootstrap')

If there is more than one group (e.g. add a row 2, dataFrameOf("x")(3)), there is no exception, but each cell is a list with one concatenated frame:

val df = dataFrameOf("key", "frames")(
        1, dataFrameOf("x")(1),
        1, dataFrameOf("x")(2),
        2, dataFrameOf("x")(3),
    )
println(result.frames[0])

gives

[       x
     Int
    ----
  0    1
  1    2
]

and

println(result.frames[1])

gives

[       x
     Int
    ----
  0    3
]
Expected

One of:

  • List<DataFrame> with the original frames: [[x=1], [x=2]] (same rule as for value columns: T → List<T>);
  • a FrameColumn with one concatenated frame: [x=1, x=2].
Possible cause

In implodeImpl, for ColumnKind.Frame the value is concat() (a DataFrame), and the type is List<AnyFrame>.

Lenguaje dominante
Kotlin
Estrellas
1.1k
Forks
87
Merge medio
2 d 21 h
PR fusionados (30 d)
40

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Kotlin/dataframe

Todos los issues de Kotlin/dataframe

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.