R.rename?
See original GitHub issueEvery now and then I wonder “should this kind of function be in Ramda?”.
I just went over the docs for Python’s Pandas
library (R-like DataFrame
s), trying to get a sense of parts it currently made more convenient. Among these was an object to rename columns in a dataframe. I couldn’t directly see a Ramda equivalent easier than some combination of pipe
, toPairs
, map
, and fromPairs
, so given that I’d propose a R.rename({ a: 'b', foo: 'bar' }, { a: 1, foo: 2 }) -> { b: 1, bar: 2 }
. Pretty random, I know, especially since Pandas is by no means a direct competitor to Ramda users. Otherwise maybe fun for cookbook.
Now to get corrected on a super-straightforward equivalent after all!
On a side-note, other bits that stood out to me from its cheat sheet as not having evident Ramda equivalents were NA handling (we’d probably end up deferring to Maybes?) / sparse data, stat-like functions e.g. binning into quartiles/percentiles, as well as maybe pivoting/unpivoting (which is kinda interesting too). Not a common comparison, I know, but that’s why I felt it’d be interesting to check. 😃
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (7 by maintainers)
Not to revive an old issue, but if someone runs into the case rewriting one or few keys, and feel like creating a custom function for
all
fields to be included seems like overkill I solved it this way:I found that you could also make creative use of
over
andlens
along withdissoc
to do a rename: