dataframe
dataframe copied to clipboard
Replace With breaks if running on `ColumnGroup` and its child
Similar to https://github.com/Kotlin/dataframe/issues/405, also replace breaks when running on both a ColumnGroup and its child.
Current implementation:
public fun <T, C> ReplaceClause<T, C>.with(transform: ColumnsContainer<T>.(DataColumn<C>) -> AnyBaseCol): DataFrame<T> {
val removeResult = df.removeImpl(columns = columns)
// removeResult.removedColumns contains the removed columns, but only the roots, so `group.child` is not
// included, just `group`, meaning `transform` will not be called on `child`
val toInsert = removeResult.removedColumns.map {
val newCol = transform(df, it.data.column as DataColumn<C>)
// pathFromRoot() returns the original path with a name change
// will be incorrect if one of its parents had a rename
ColumnToInsert(it.pathFromRoot().dropLast(1) + newCol.name, newCol, it)
}
return removeResult.df.insertImpl(toInsert)
}
Also need to look into move for similar behavior.
could also provide a warning in the meantime