熊猫速度太慢有条件替换

时间:2019-09-14 13:10:00

标签: python-3.x pandas performance jupyter-notebook iteration

我正在尝试从另一列替换某一列的值,但是它太慢了,与该条件匹配的行数约为5000

 for index, row in voter.iterrows(): 
    if row['TOTINC'] == 0:
        voter['TOTINC'][index] = voter['INC'][index]

有什么方法可以使其更快,因为这大约需要40-50秒

0 个答案:

没有答案