`implode` on a `FrameColumn` gives inconsistent results

Aperta
#2,185 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
kotlin
Ambito
data

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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>.

Lingua principale
Kotlin
Stelle
1.1k
Fork
87
Merge medio
2g 21h
PR unite (30g)
40

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Kotlin/dataframe

Tutte le issue di Kotlin/dataframe

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.