Python 向数据帧添加列

Python 向数据帧添加列,python,dataframe,append,Python,Dataframe,Append,我有这样一个数据帧: case is1 is5 is10 im1 im5 im10 686 0.1406 0.2997 0.1490 0.1339 0.1350 0.1417 950 0.1602 0.3448 0.1719 0.0884 0.0962 0.1385 1005 0.1641 0.2606 0.1507 0.1306 0.1613 0.1328 1005 0.1456 0.309

我有这样一个数据帧:

case    is1     is5     is10    im1     im5     im10
686     0.1406  0.2997  0.1490  0.1339  0.1350  0.1417
950     0.1602  0.3448  0.1719  0.0884  0.0962  0.1385
1005    0.1641  0.2606  0.1507  0.1306  0.1613  0.1328
1005    0.1456  0.3097  0.1825  0.1116  0.1295  0.1211
我想用公式添加第八列,比如

const1*is1+const2*is2+...const6*im10

我该怎么做呢?

类似的方法可能会奏效

df['new col']=const1*df['is1']+.....+const6*df['im10']
试试这个

df['8thcol'] = df.apply(lambda x: x[' is1'] + x[' is5'] + x[' is10'] + \
                                x['im1'] + x['im5']+ x['im10'], axis=1)
const = 5 # any constant value
df['8thcol']  = df.8thcol * const 

df