0

I have a dataframe like this:

      A            B        C
396  1147.430  1147.219  0.000184
397  1147.110  1147.630 -0.000453
398  1146.870  1147.469 -0.000522
399  1147.110  1147.680 -0.000497
400  1147.170  1147.640 -0.000410
401  1147.210  1147.430 -0.000192

I want to take the Nth power for each cell in Column C and add them up. I know for squares I can use np.square(df['C']).sum(axis=0).
Is there a quick way to do this for other powers?

ayhan
  • 70,170
  • 20
  • 182
  • 203
Cofeinnie Bonda
  • 309
  • 2
  • 4
  • 13

1 Answers1

2
df['C'].pow(3).sum()
Out: -4.2772918200000004e-10

Or,

(df['C']**3).sum()
Out: -4.2772918200000004e-10
ayhan
  • 70,170
  • 20
  • 182
  • 203