Replies: 2 comments
-
That is a good idea. Also, modifiers - |
Beta Was this translation helpful? Give feedback.
0 replies
-
this has been resolved with the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think our current API lacks somewhat when it comes to renaming columns in the j section. The "normal" API is to use a dict:
{"newA": f.A, "newB": f.B, ...}
. However, a common use-case is when you want to select some columns as-is, and also some new columns with names. In this case repeating names of all columns may be too difficult or even impossible.A possible workaround is to use the
.extend()
method. However, this has its own drawbacks:DT[:, [f.A, f.B, f.C]]
and then decide that you need to rename, say, columnB
, then you end up having to completely rewrite the formula intoDT[:, f.A.extend({"newB": f.B}).extend(f.C)]
.The solution that I'm proposing is to have a new method
.as()
that could rename an individual f-expression. For example:(the name is inspired by the equivalent SQL keyword).
Similarly, you can apply this to a columnset and rename multiple columns at once:
Beta Was this translation helpful? Give feedback.
All reactions