2016-06-24 10 views

Antwort

0

ist das was du willst?

In [38]: from itertools import combinations 

In [40]: df 
Out[40]: 
    Sn.No Series_A Series_B Series_C 
0  1  10  17  12 
1  2  11  13  15 
2  3  13  15  13 

In [41]: cols = df.filter(like='Series_').columns 

In [42]: cols 
Out[42]: Index(['Series_A', 'Series_B', 'Series_C'], dtype='object') 

In [43]: for c in combinations(cols, 2): 
    ....:   colname = '{}_{}'.format(c[0].lstrip('Series_'), c[1].lstrip('Series_')) 
    ....:   df[colname] = df[c[0]] - df[c[1]] 
    ....: 

In [44]: df 
Out[44]: 
    Sn.No Series_A Series_B Series_C A_B A_C B_C 
0  1  10  17  12 -7 -2 5 
1  2  11  13  15 -2 -4 -2 
2  3  13  15  13 -2 0 2