holgerbrandl/krangl

DataFrame.setNames() waiting String argument

carloseguevara opened this issue · 2 comments

The function "setNames" is defined to change all the column names of the current DataFrame, but not is be able to receive an array list with the new column names, only accept a single String. Maybe I'm currently a bad use of this function.

fun DataFrame.setNames(vararg newNames: String): DataFrame =
        rename(*names.zip(newNames).map { (old, new) -> old to new }.toTypedArray())

I think you may not using it as intended because it accepts a vararg:

df.setNames("foo", "bar", "bla")

// or if you have a list of names
msleep.setNames(*listOf("foo","bar").toTypedArray())

There's also rename() to selectively rename certain columns.

Does this answer your question?

Yes, thanks! I wasn't sure if I was using the function in the correct way.