The following works:
# Import data processing and graphing packages
import os,sys
from math import *
import numpy as np
import pandas as pd
# import scipy
import matplotlib.pyplot as plt
from matplotlib import style
style.use(['ggplot', 'fast'])
plt.ion() # Plot interactively
#
# Create pandas DataFrame
tm = range(26)
tm = np.array(tm)*0.003
#
sf1 = [ 0. , 0.24862903, 0.48164355, 0.68440969, 0.84419323,
0.95095939, 0.99800299, 0.98236957, 0.90504096, 0.77087357,
0.58829346, 0.36876708, 0.12608123, -0.12452282, -0.36730654,
-0.58702251, -0.76987205, -0.90437174, -0.9820747 , -0.99810098,
-0.95144409, -0.8450342 , -0.68555411, -0.48301955, -0.25015019,
0.]
#
sf2 = [ 0.8660254 , 0.71451664, 0.51813449, 0.28921224, 0.04212676,
-0.20760439, -0.44429747, -0.6530876 , -0.82086223, -0.93708473,
-0.99445602, -0.98937306, -0.92215507, -0.7970235 , -0.62183691,
-0.40759746, -0.16775989, 0.0826134 , 0.32779837, 0.55239681,
0.74230338, 0.8855915 , 0.97326232, 0.9998099 , 0.96356699,
0.8660254]
#
sf3 = [-0.8660254 , -0.96314567, -0.99977804, -0.97362193, -0.88631999,
-0.743355 , -0.55370551, -0.32928197, -0.08417872, 0.16621115,
0.40616257, 0.62060598, 0.79607383, 0.92154632, 0.98914345,
0.99461997, 0.93763194, 0.82175834, 0.65427633, 0.44570417,
0.2091407 , -0.04055731, -0.28770822, -0.51679035, -0.7134168,
-0.8660254]
#
pdat = pd.DataFrame({'sf1': sf1, 'sf2': sf2, 'sf3': sf3}, index = tm)
# Add columns
pdat['sf1_2'] = np.power(pdat.loc[:,'sf1'],2)
pdat['sf2_2'] = np.power(pdat.loc[:,'sf2'],2)
pdat['sf3_2'] = np.power(pdat.loc[:,'sf3'],2)
pdat['sfssq'] = pdat.loc[:,'sf1_2']+pdat.loc[:,'sf2_2']+pdat.loc[:,'sf3_2']
meansq = np.mean(pdat.loc[:,'sfssq'])/3
rms = sqrt(meansq)
print 'Mean Square = ', meansq, ', RMS = ', rms
pdat.plot()
--------
I have 14 sets of three columns to do this to, plus product columns
(for power) plus filtering, plus some miscellaneous calculations, all on
data sets approaching a million rows. It would of course be more
elegant to do it in one go, but this will get the job done.
Thanks everyone for the help.
Regards,
Allen