Skip to content

Adding column name to its respective value? #3187

Answered by lmullany
SMOK1N-ACES asked this question in Q&A
Discussion options

You must be logged in to vote

Hmm, is this the type of loop you were trying to avoid?

data = dt.Frame(First=["t","r","s"],Middle=["p","q","r"],Last=["a","b","c"])
for col in data.names:
    data[col] = data[:, col + " / " + f[col]]

output:

   | First      Middle      Last    
   | str32      str32       str32   
-- + ---------  ----------  --------
 0 | First / t  Middle / p  Last / a
 1 | First / r  Middle / q  Last / b
 2 | First / s  Middle / r  Last / c

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@SMOK1N-ACES
Comment options

@oleksiyskononenko
Comment options

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