Skip to content

How to add new column #2702

Answered by st-pasha
santoshbs asked this question in Q&A
Oct 20, 2020 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Yes, you can either use an assignment statement, or the update() function:

DT["newcol"] = <expression> # or
DT[:, update(newcol=<expression>)]

where <expression> is any formula involving other columns. For example:

DT[:, update(Revenue = f.Quantity * f.Price)]

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@santoshbs
Comment options

@st-pasha
Comment options

Answer selected by st-pasha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants