diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt index 84b2446d7b..988f7bc3b9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/implode.kt @@ -30,8 +30,14 @@ internal fun DataFrame.implodeImpl(dropNA: Boolean = false, columns: C first = false value } else { - null + // these rows will not be taken into account, + // but we cannot leave them empty, as `map` creates a full column + when (column.kind()) { + ColumnKind.Value -> emptyList() + ColumnKind.Group -> DataFrame.empty() + ColumnKind.Frame -> emptyList() + } } } - }[0..0] + }[0..0] // takes only the first row }.concat() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index aef3f08b83..eac43db02b 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.impl.isArray import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray +import org.jetbrains.kotlinx.dataframe.kind import kotlin.reflect.KClass import kotlin.reflect.KType import kotlin.reflect.full.isSubclassOf @@ -37,7 +38,7 @@ internal abstract class DataColumnImpl( if (BuildConfig.DEBUG) { require(values.all { it matches type }) { val types = values.map { if (it == null) "Nothing?" else it!!::class.simpleName }.distinct() - "Values of column '$name' have types '$types' which are not compatible given with column type '$type'" + "Values of $kind '$name' have types '$types' which are not compatible given with column type '$type'" } } }