-
Notifications
You must be signed in to change notification settings - Fork 73
Adds the parent name in the flatten operation #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Don't forget to regenerate docs, any build/assemble call will do so. Maybe it's a good idea to make this behavior optional? I can see many cases where flattening should result in all child columns with their actual name, not including the parent name. |
Could you please share the case, I will add it to the tests and could make ot optional |
Just take any Dataframe containing some column groups where the children (value- or frame-columns) names are unique and flatten it. This should produce a new data frame with all value- and frame-columns regardless of whether they were nested in a column group or not |
In SQL, it's done by default, you know all this stuff: "MAX (name)" and so on. |
@zaleslaw "keepParentNameForColumns" is a bit long isn't it? Also, "forColumns" is a bit redundant IMO. I'd consider something like "renameByPath". |
@@ -29,7 +30,8 @@ internal fun <T, C> DataFrame<T>.flattenImpl( | |||
.into { | |||
val targetPath = getRootPrefix(it.path).dropLast(1) | |||
val nameGen = nameGenerators[targetPath]!! | |||
val name = nameGen.addUnique(it.name()) | |||
val preferredName = if (keepParentNameForColumns) "${it.name()}.${it.parentName}" else it.name() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is the wrong way around, should be parentName.name instead.
Fixes #229