`implode` on a `FrameColumn` gives inconsistent results

オープン
#2,185 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
64/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
kotlin
領域
data

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Kotlin
スター
1.1k
フォーク
87
平均マージ
2日 21時間
マージ済み PR(30日)
40

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Kotlin/dataframe のほかの issue

Kotlin/dataframe の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。