在進行數(shù)據(jù)操作時,經常會根據(jù)條件批量的修改數(shù)據(jù),如以下數(shù)據(jù),按照日期的條件,將部門日期下的promotion改為1
在五峰等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站設計、網(wǎng)站建設 網(wǎng)站設計制作按需求定制開發(fā),公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,高端網(wǎng)站設計,營銷型網(wǎng)站,外貿營銷網(wǎng)站建設,五峰網(wǎng)站建設費用合理。
tot_qty | price | date | price_delta1 | price_delta2 | price_delta3 | promotion | |
---|---|---|---|---|---|---|---|
created_date | |||||||
20160419 | 1.0 | 5.410000 | 20160419 | NaN | NaN | NaN | 0 |
20161111 | 96.0 | 5.400000 | 20161111 | -0.010000 | NaN | NaN | 1 |
20161123 | 1.0 | 7.500000 | 20161123 | 2.100000 | 2.090000 | NaN | 0 |
20161213 | 5.0 | 7.500000 | 20161213 | 0.000000 | 2.100000 | 2.090000 | 0 |
20161226 | 37.0 | 6.258571 | 20161226 | -1.241429 | -1.241429 | 0.858571 | 0 |
方法:遍歷每一行,判斷條件,執(zhí)行修改
for i in range(len(data)): line=data.iloc[i,:] if line['date']in (20170416,20170417,20170418,20170616,20170617,20170618,20170816,20170817,20170818,20171109,20171110,20171111): data[i:i+1]['promotion']=1