在问这个问题之前,我试图彻底研究这个问题。我正在尝试绘制字典中包含的两个列表的比例。
line_ids = ['blah1','blah2','blah3','blah4']
elines = {}
for i in range(0,len(line_ids)):
data = []
with open('../output/'+line_ids[i]+'.csv', 'rb') as f:
csvReader = csv.reader(f, delimiter='\t')
for row in csvReader:
data.append(row)
elines[line_ids[i]] = asarray(data)
从字典中打印elines ['blah1']给出了
[['4.6976281459143071e-40' '3.0049306872382702e-39'
'1.9820026838968144e-38' '1.6041105541709449e-37']
['1.542746402089586e-35' '9.8686046391594954e-35' '6.5092653777796069e-34'
'5.2672534967984846e-33']
['5.1441760072407447e-31' '3.2907875381847918e-30'
'2.1708144830971927e-29' '1.7560195950953601e-28']
['1.7569718535756951e-26' '1.1242245080095899e-25'
'7.4206530085692796e-25' '6.0042313952458629e-24']
['6.2845797115752487e-22' '4.0257542124265526e-21' '2.66528748586604e-20'
'2.1666107897620966e-19']
['2.5547831152324016e-17' '1.6442300355147718e-16'
'1.1022166700730511e-15' '9.1504695119123154e-15']
['1.5754213462395474e-12' '1.0263716591948211e-11'
'7.0896658599931989e-11' '6.1192748118049791e-10']
['2.1154710788925884e-07' '1.3897595085341154e-06'
'9.7645963829243462e-06' '8.3998195937762357e-05']
['0.048187475948250416' '0.31578185949368143' '2.1989098794898618'
'18.120232380010545']
['13029.442003642062' '84972.769876238017' '583770.26053237868'
'4613639.5426874915']
['3726334731.7746887' '24202150828.792419' '164441556532.18036'
'1258809063091.2998']
['1095752351035507.6' '7094645944427608.0' '47806778370222816.0'
'3.5753379508453267e+17']
['3.2816291840091796e+20' '2.1198307401280088e+21'
'1.4197379061068677e+22' '1.0439706837407766e+23']
['9.9600859087036886e+25' '6.4228680979461599e+26'
'4.2823746950774039e+27' '3.1104137359015335e+28']
['3.0534668934520022e+31' '1.9665558653862894e+32'
'1.3068413234720059e+33' '9.406936707924414e+33']
['9.4324018968341618e+36' '6.0691075771818466e+37'
'4.0232499374256741e+38' '2.8769493880535716e+39']]
当我尝试划分两个列表时,运行脚本时会得到以下内容
print divide(elines['blah1'][0],elines['blah2'][0])
NotImplemented
我认为它可能与列表中被视为字符串的数字有关,所以我尝试使用float()函数转换它们,但我得到一个说法只有length-1数组可以转换为Python标量。理想情况下,我想绘制blah1的第1列与第2列的第1列,blah1的第2列与第2列的第2列等等。
非常感谢任何帮助。谢谢!