Skip to content

Commit d463133

Browse files
authored
Merge pull request #801 from Kotlin/implodeFix
Small implode fix
2 parents acafb6d + e4a3af5 commit d463133

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ internal fun <T, C> DataFrame<T>.implodeImpl(dropNA: Boolean = false, columns: C
3030
first = false
3131
value
3232
} else {
33-
null
33+
// these rows will not be taken into account,
34+
// but we cannot leave them empty, as `map` creates a full column
35+
when (column.kind()) {
36+
ColumnKind.Value -> emptyList<Any?>()
37+
ColumnKind.Group -> DataFrame.empty()
38+
ColumnKind.Frame -> emptyList<AnyFrame>()
39+
}
3440
}
3541
}
36-
}[0..0]
42+
}[0..0] // takes only the first row
3743
}.concat()

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn
55
import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
66
import org.jetbrains.kotlinx.dataframe.impl.isArray
77
import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray
8+
import org.jetbrains.kotlinx.dataframe.kind
89
import kotlin.reflect.KClass
910
import kotlin.reflect.KType
1011
import kotlin.reflect.full.isSubclassOf
@@ -37,7 +38,7 @@ internal abstract class DataColumnImpl<T>(
3738
if (BuildConfig.DEBUG) {
3839
require(values.all { it matches type }) {
3940
val types = values.map { if (it == null) "Nothing?" else it!!::class.simpleName }.distinct()
40-
"Values of column '$name' have types '$types' which are not compatible given with column type '$type'"
41+
"Values of $kind '$name' have types '$types' which are not compatible given with column type '$type'"
4142
}
4243
}
4344
}

0 commit comments

Comments
 (0)