f = pd.read_csv(location,delimiter='\t\t',skiprows=2)
f['DFA'] = 'http://10.209.81.36/Binary_dfa_NSS_sorted_2464.txt'
在运行脚本时,
我将列作为
http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
而不是http://10.209.81.36/Binary_dfa_NSS_sorted_2464.txt
完整代码:
#!/usr/bin/python
import time
import os,sys
from os import path
import re
import sys, ast
import subprocess
import numpy as np
#from StringIO import StringIO
import pandas as pd
pd.set_option('display.max_columns', 500)
location = "/root/madhu_test/bpstest/results/finalnss.txt"
with open (location, "r") as myfile:
data=myfile.read().replace('\n', ' ')
print data
#print location
f = pd.read_csv(location,delimiter='\t\t',skiprows=2)
#f.apply(pd.Series.round)
#print f
cols = f.columns.tolist()
print cols
f = f.drop('BPS Profile.2', 1)
f = f.drop('BPS Profile.1', 1)
np.radians(f['Throughput'])
np.radians(f['Throughput.1'])
f.Throughput = f.Throughput.round()
f['Throughput.1'] = f['Throughput.1'].round()
f['percentage'] = ((f['Throughput.1']-f['Throughput'])/f['Throughput.1'])*100.0
f['percentage.1'] = ((f['Throughput.2']-f['Throughput'])/f['Throughput.2'])*100.0
f['Throughput.2'] = f['Throughput.2'].round()
f.percentage = f.percentage.round(1)
f['percentage.1'] = f['percentage.1'].round(1)
f['DFA'] = 'http://10.209.81.36/Binary_dfa_NSS_sorted_2464.txt'
print f
cols = f.columns.tolist()
#print cols
cols = ['BPS Profile', 'Throughput', 'DFA', 'Throughput.1', 'percentage', 'Throughput.2','percentage.1']
f = f[cols]
f.columns = ['BPS Profile', '2464 Throughput', '2464 DFA', '2482 Throughput', 'percentage', '2483 Throughput','Percentage']
f.to_html('/root/madhu_test/bpstest/results/outnss.html')
在运行时我得到了这个输出:
['BPS Profile', 'Throughput', 'BPS Profile.1', 'Throughput.1', 'BPS Profile.2', 'Throughput.2']
BPS Profile Throughput Throughput.1 Throughput.2 percentage \
0 SigTestHTTP21kBin 217 219 453 0.9
1 SigTestHTTP21kHtml 359 364 372 1.4
2 SigTestHTTP21kText 380 376 378 -1.1
3 NSS-HTTP21Kdelay 378 380 378 0.5
4 NSS-HTTPCPS 18920 75 76 -25126.7
5 SIggTestPerimeter 270 223 232 -21.1
6 SIgTestDatacenter 371 373 361 0.5
7 NSS-Financial 5 56 57 91.1
8 NSS-Education 971 1010 958 3.9
9 NSS-EuroMobile 921 933 942 1.3
10 NSS-USMobile 528 542 633 2.6
percentage.1 DFA
0 52.0 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
1 3.4 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
2 -0.6 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
3 0.0 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
4 -24821.0 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
5 -16.2 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
6 -2.7 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
7 91.2 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
8 -1.4 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
9 2.2 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...
10 16.5 http://10.209.81.36/Binary_dfa_NSS_sorted_2464...