python_prog2_przyklad_dane

2098 days ago by macieksk

%python import urllib urllib.urlretrieve('http://escher.fuw.edu.pl/~mm/KAMIL/kamil_eksp_1290627532.3900001.txt','data/keksp.txt') 
       
('data/keksp.txt', <httplib.HTTPMessage instance at
0x5d7db48>)
import os os.system('head data/keksp.txt ') 
       
word,group,word_time,answer,answer_time,
choroba,Neg1,0.0320023913653813,3,2.624789184100166,
przemoc,Neg1,0.032018594542023493,2,1.6803772546510345,
śmierć,Neg1,0.018968332567453672,4,1.1525557019118082,
zagrożenie,Neg1,0.032012169144365998,4,2.2727123139952141,
zakażenie,Neg1,0.018934808753613197,3,2.1444775802511344,
zniewolenie,Neg1,0.018319926135916376,5,1.6165470751170687,
cierpienie,Neg1,0.032006581842097148,3,1.9046350863028465,
bezradność,Neg1,0.018448434088725207,4,1.7124355190394454,
panika,Neg1,0.019095164329542058,4,0.89662624719062478,
0
import numpy as np help(np.loadtxt) 
       
data=np.loadtxt('data/keksp.txt', delimiter=',', skiprows=1, # pomin nazwy kolumn dtype=float, usecols=[2,3,4]) print data 
       
[[  3.20023914e-02   3.00000000e+00   2.62478918e+00]
 [  3.20185945e-02   2.00000000e+00   1.68037725e+00]
 [  1.89683326e-02   4.00000000e+00   1.15255570e+00]
 [  3.20121691e-02   4.00000000e+00   2.27271231e+00]
 [  1.89348088e-02   3.00000000e+00   2.14447758e+00]
 [  1.83199261e-02   5.00000000e+00   1.61654708e+00]
 [  3.20065818e-02   3.00000000e+00   1.90463509e+00]
 [  1.84484341e-02   4.00000000e+00   1.71243552e+00]
 [  1.90951643e-02   4.00000000e+00   8.96626247e-01]
 [  1.87836722e-02   5.00000000e+00   1.53628352e+00]
 [  3.20068612e-02   3.00000000e+00   1.90441858e+00]
 [  3.19948485e-02   3.00000000e+00   2.01672475e+00]
 [  1.86481801e-02   2.00000000e+00   1.44055627e+00]
 [  3.20261374e-02   2.00000000e+00   1.77660736e+00]
 [  3.19887025e-02   1.00000000e+00   1.72884459e+00]
 [  3.20051850e-02   1.00000000e+00   7.36426557e-01]
 [  3.19590898e-02   1.00000000e+00   1.23252173e+00]
 [  1.88973738e-02   1.00000000e+00   8.00640864e-01]
 [  3.19400929e-02   1.00000000e+00   6.08464204e-01]
 [  3.19839533e-02   1.00000000e+00   9.62683805e-02]
 [  3.20029501e-02   1.00000000e+00   2.56736541e-04]
 [  3.20350771e-02   1.00000000e+00   1.92537599e-01]
 [  1.90412469e-02   1.00000000e+00   2.64084569e+00]
 [  3.20146834e-02   2.00000000e+00   1.08863585e+00]
 [  3.20158009e-02   3.00000000e+00   1.10448702e+00]
 [  3.20026707e-02   3.00000000e+00   6.88424367e-01]
 [  3.20037882e-02   3.00000000e+00   1.13647265e+00]
 [  3.19976422e-02   4.00000000e+00   6.88383300e-01]
 [  3.19951279e-02   4.00000000e+00   2.76866948e+00]
 [  3.19923342e-02   4.00000000e+00   8.64244199e-01]
 [  3.20177564e-02   4.00000000e+00   1.88870261e+00]
 [  1.84341865e-02   5.00000000e+00   3.13691237e+00]
 [  3.20158009e-02   5.00000000e+00   9.60525151e-01]
 [  3.20090961e-02   5.00000000e+00   2.88298373e-01]
 [  3.19792041e-02   5.00000000e+00   8.80446817e-01]
 [  3.20183152e-02   5.00000000e+00   9.28547343e-01]
 [  3.20121691e-02   4.00000000e+00   1.55242999e+00]
 [  3.20096549e-02   4.00000000e+00   7.20527050e-01]
 [  3.20180358e-02   5.00000000e+00   4.00435530e-01]
 [  3.20211088e-02   5.00000000e+00   1.76070199e+00]
 [  3.19772485e-02   3.00000000e+00   1.85643483e+00]
 [  1.87456786e-02   3.00000000e+00   1.08877050e+00]
 [  3.20141247e-02   3.00000000e+00   9.12422948e-01]
 [  3.19993183e-02   3.00000000e+00   4.64307615e-01]
 [  3.19747342e-02   3.00000000e+00   8.32618112e-01]
 [  3.19792041e-02   3.00000000e+00   4.96395212e-01]
 [  3.19236104e-02   3.00000000e+00   6.88531922e-01]
 [  3.20160803e-02   3.00000000e+00   6.24396117e-01]
 [  3.19870263e-02   3.00000000e+00   4.32343217e-01]
 [  3.20364739e-02   3.00000000e+00   4.80399604e-01]
 [  1.90177802e-02   3.00000000e+00   8.16467177e-01]
 [  3.20057437e-02   2.00000000e+00   7.68440961e-01]
 [  3.20001564e-02   2.00000000e+00   3.84392709e-01]
 [  3.20074199e-02   2.00000000e+00   4.32111902e-01]
 [  3.20135660e-02   2.00000000e+00   6.72261698e-01]
 [  1.87210944e-02   2.00000000e+00   8.32613363e-01]
 [  3.20118898e-02   2.00000000e+00   4.48050520e-01]
 [  3.20074199e-02   4.00000000e+00   2.00073138e+00]
 [  3.20037882e-02   4.00000000e+00   2.88472138e-01]
 [  3.20132866e-02   4.00000000e+00   2.72425406e-01]
 [  3.21694517e-02   5.00000000e+00   4.48350279e-01]
 [  1.82347198e-02   5.00000000e+00   4.32398252e-01]
 [  3.19875850e-02   5.00000000e+00   4.96170044e-01]
 [  3.20124485e-02   5.00000000e+00   4.00440000e-01]
 [  3.19987596e-02   3.00000000e+00   1.72857807e+00]
 [  3.20146834e-02   3.00000000e+00   5.28515775e-01]
 [  3.20183152e-02   3.00000000e+00   4.32316118e-01]
 [  3.20096549e-02   3.00000000e+00   3.04288674e-01]
 [  3.20035088e-02   3.00000000e+00   4.48339384e-01]
 [  3.20057437e-02   2.00000000e+00   5.60367309e-01]
 [  3.20205501e-02   2.00000000e+00   4.16302631e-01]
 [  3.20065818e-02   2.00000000e+00   5.92169955e-01]]