擅长:python、mysql、java
<p>您正在将序列与标量值进行比较。combine是一个系列,而100是一个数值。你知道吗</p>
<p>您可以将序列转换为数据帧并传递到函数中。你知道吗</p>
<pre><code>def modify_to_100(df):
df['new'] = df['first'] + df['second']
# df['new'] = np.where(df['new']!=100, 100, df['new'])
while True:
if all(df['new'].eq(100)):
break
df[df['new']<100] = df['new']+1
return df['new'].values
first = pd.Series([50, 60, 40])
second = pd.Series([20, 10, 40])
print(modify_to_100(pd.DataFrame({'first':first.values, 'second':second.values})))
</code></pre>