python - Summing columns to form a new dataframe -
i have dataframe
b c d 2015-07-18 4.534390e+05 2.990611e+05 5.706540e+05 4.554383e+05 2015-07-22 3.991351e+05 2.606576e+05 3.876394e+05 4.019723e+05 2015-08-07 1.085791e+05 8.215599e+04 1.356295e+05 1.096541e+05 2015-08-19 1.397305e+06 8.681048e+05 1.672141e+06 1.403100e+06 ... i want sum columns new dataframe
b c d sum s s s s with columnwise sums , print to_csv(). when use
df.sum(axis=0) print(df) 9.099377e+06 b 5.897003e+06 c 1.049932e+07 d 9.208681e+06 dtype: float64
you can transform df.sum() dataframe , transpose it:
in [39]: df.sum().to_frame('sum').t out[39]: b c d sum 2358458.2 1509979.49 2766063.9 2370164.7
Comments
Post a Comment