sbelak / huri

Tools for the lazy data scientist
Eclipse Public License 1.0
225 stars 17 forks source link

add function to rename cols #8

Open behrica opened 7 years ago

behrica commented 7 years ago

I implemented it for me like this:

(defn rename-cols [renames df]
   (map #(clojure.set/rename-keys % renames) df)
  )

It is a rather trivial function, so I am not sure if you want to have it in huri.core.

If you are interested, I could make a PR

sbelak commented 7 years ago

Out of curiosity, what's the use case for renaming? I've never felt the need, but if I had to whip up something I'd probably use derive-cols with identity. Not categorically against including this, just want to understand the use cases better to see how widely applicable it is.

behrica commented 7 years ago

I read my tables from csvs/excel and sometimes the column names are too ugyl.. Or I want to join, and need to make the join column the same name.

"derive" alone would not do it, as it needed 'derive' to make a copy and "select-cols" to remove the old one.

I am used to dplyr... so look for "similar" functions.

but indeed, rename coul be implemented by using derive + select. (to remove the former one)