Skip to content
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

renameToCamelCase for columns with names starting with capital letter should lowercase it #302

Closed
belovrv opened this issue Mar 15, 2023 · 4 comments · Fixed by #379
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@belovrv
Copy link
Collaborator

belovrv commented Mar 15, 2023

No description provided.

@Jolanrensen Jolanrensen changed the title renameToCamelCase for columns started with capital letter should lowercase it renameToCamelCase for columns with names starting with capital letter should lowercase it Mar 15, 2023
@zaleslaw zaleslaw self-assigned this Apr 4, 2023
@Jolanrensen Jolanrensen added this to the 0.11.0 milestone Apr 6, 2023
@zaleslaw zaleslaw added the enhancement New feature or request label Apr 17, 2023
@zaleslaw
Copy link
Collaborator

zaleslaw commented May 4, 2023

@belovrv what kind of CamelCase do you want?

  • CamelCase?
  • camelCase? (style lowerCamelCase) <-------- this one, isn't it?

Why am I asking? Because for now, looks like the function doing what you want, it makes from column name "another_name" -> "anotherName"

Or do you want to get in this case "AnotherName" ? But it's uppercase CamelCase

For now, we have no documentation for this function, please give some examples of usage or share some insights

@zaleslaw
Copy link
Collaborator

zaleslaw commented May 4, 2023

@Jolanrensen how do you estimate this code?

For me, it looks like a strange 2-3 level repeating function s with recursive call.

If it's a common pattern to apply changes in the dataframe, could you advise how to interpret correctly the code?


public fun <T> DataFrame<T>.renameToCamelCase(): DataFrame<T> {
    return rename {
        dfs { it.isColumnGroup() && it.name() matches DELIMITED_STRING_REGEX }
    }.toCamelCase()
        .rename {
            dfs { !it.isColumnGroup() && it.name() matches DELIMITED_STRING_REGEX }
        }.toCamelCase()
        .update {
            dfsOf<AnyFrame>()
        }.with { it.renameToCamelCase() }
}

@Jolanrensen
Copy link
Collaborator

Jolanrensen commented May 5, 2023

@zaleslaw
It says:
First, recursively rename all column groups to camel case,
then recursively rename all other columns to camel case,
then finally, take all frame columns recursively and call renameToCamelCase() on all dataframes inside.

It might look clearer after my rename:

public fun <T> DataFrame<T>.renameToCamelCase(): DataFrame<T> = this
    .rename {
        // rename groups first, because groups and their children cannot be renamed/moved at the same time
        groups { it.name() matches DELIMITED_STRING_REGEX }.recursively()
    }.toCamelCase()

    .rename {
        cols { it.name() matches DELIMITED_STRING_REGEX }.recursively(includeGroups = false)
    }.toCamelCase()

    .update {
        colsOf<AnyFrame>().recursively()
    }.with { it.renameToCamelCase() }

@belovrv
Copy link
Collaborator Author

belovrv commented May 11, 2023

Now if you have ColumnName, it will convert it to ColumnName, and I prefer columnName, which is Kotlin style property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants