擅长:python、mysql、java
<p>我觉得最简单。</p>
<pre><code>from random import randint, randrange, uniform
import pandas as pd
import numpy as np
df = pd.DataFrame({'a':randrange(0,10),'b':randrange(10,20),'c':np.random.randn(10)})
#If colC > 0,5, then ColC = ColB - Cola
df['c'][df['c'] > 0.5] = df['b'] - df['a']
</code></pre>
<p>经过测试,它是有效的。</p>
<pre><code>a b c
2 11 -0.576309
2 11 -0.578449
2 11 -1.085822
2 11 9.000000
2 11 9.000000
2 11 -1.081405
</code></pre>