Skip to content

Commit

Permalink
Merge pull request #801 from Kotlin/implodeFix
Browse files Browse the repository at this point in the history
Small implode fix
  • Loading branch information
Jolanrensen authored Aug 1, 2024
2 parents acafb6d + e4a3af5 commit d463133
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ internal fun <T, C> DataFrame<T>.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<Any?>()
ColumnKind.Group -> DataFrame.empty()
ColumnKind.Frame -> emptyList<AnyFrame>()
}
}
}
}[0..0]
}[0..0] // takes only the first row
}.concat()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -37,7 +38,7 @@ internal abstract class DataColumnImpl<T>(
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'"
}
}
}
Expand Down

0 comments on commit d463133

Please sign in to comment.