Python/Pandas-求和数据帧列项

Python/Pandas-求和数据帧列项,python,pandas,Python,Pandas,我有以下数据帧: Value Seasonal Date 2004-01-01 0 -10.000000 2004-02-01 173 -50.000000 2004-03-01 225 0.000000 2004-04-01 230 9.000000 我想对它的项目进行求和,这样就可以得到: Value Date

我有以下数据帧:

            Value   Seasonal
Date                        
2004-01-01      0 -10.000000
2004-02-01    173 -50.000000
2004-03-01    225   0.000000
2004-04-01    230   9.000000
我想对它的项目进行求和,这样就可以得到:

                   Value 
Date                        
2004-01-01    -10.000000
2004-02-01    123.000000
2004-03-01    225.000000
2004-04-01    239.000000
有没有简单的方法可以做到这一点?

您可以:

df['Value'] = df['Value'] + df['Seasonal']

如果您想创建一个全新的数据帧,而不会弄乱旧的数据帧

import pandas as pd

In [12]: pd.DataFrame({"Date": df["Date"], "Value": df["Value"] + df["Seasonal"]})
Out[12]: 
         Date  Value
0  2004-01-01    -10
1  2004-02-01    123
2  2004-03-01    225
3  2004-04-01    239

df.Value+=df.季节性
df['Value'] += df['Seasonal']
dfnew = df.drop('Seasonal', axis=1)
print(dfnew)

Output:
Date  Value
0  2004-01-01    -10
1  2004-02-01    123
2  2004-03-01    225
3  2004-04-01    239