Preview:
df = pd.DataFrame({'A': [-3, 7, 4, 0], 'B': [-6, -1, 2, -8], 'C': [1, 2, 3, 4]})

#it goes through column A, selects where it's negative & replaces with 2, or if it's not negative it puts in the values from column C
df.A = np.where(df.A < 0, 2, df.C)


#it goes through column A, selects where it's negative & replaces with 2, or if it's not negative it leaves it as is
df.A = np.where(df.A < 0, 2, df.A)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter