Skip to content

If statement in expression / virtual column #1804

Answered by maartenbreddels
abf7d asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

debug tip: If you print this out (in the repr) you'll probably see what is evaluates into

df['original_col']) if df['original_col'] == 0 else -4

you can use where instead:

(df['original_col']) == 0).where(df['original_col'], -4)

Hope that helps

cheers,

Maarten

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@abf7d
Comment options

Answer selected by abf7d
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
Converted from issue

This discussion was converted from issue #1803 on December 29, 2021 10:16.