Hallo, ich habe in Python eine Liste mit zwei reihen und möchte diese gerne Plotten. Aber ich denke, irgendwas stimmt mit dem Format nicht. Dabei handelt es sich um Uhrzeiten und Preise die ich aus einer HTML auswerte.
1 | datas=[] |
1 | for absatz in absaetze: |
2 | priceTemp = absatz.find('span', attrs = {'class' : 'fareOutput'}) |
3 | temp = priceTemp.text.split() |
4 | y = temp[len(temp)-2] |
5 | #print(y[len(y)-2]) |
6 | |
7 | dateTemp = absatz.find_all('a')[1] |
8 | temp = str(dateTemp).split() |
9 | x = temp[len(temp)-2] |
10 | #print(x[len(x)-2]) |
11 | |
12 | #print(x[len(x)-2] + '\t' + y[len(y)-2]) |
13 | datas.append([x,y]) |
14 | |
15 | data=np.array(datas) |
das ergibt folgende Ausgabe datas:
1 | [['07:06', '22,90'], ['07:38', '24,90'], ['08:38', '24,90'], ['21:38', '24,90'], ['22:38', '24,90'], ['09:38', '26,90'], ['10:38', '26,90'], ['20:06', '26,90'], ['09:06', '39,90'], ['10:06', '39,90'], ['19:38', '39,90'], ['20:38', '39,90'], ['13:03', '43,90'], ['11:38', '45,90'], ['12:06', '45,90'], ['12:38', '45,90'], ['14:03', '45,90'], ['16:38', '45,90'], ['17:38', '45,90'], ['14:38', '47,90'], ['16:03', '49,90'], ['18:38', '49,90'], ['15:38', '51,90'], ['18:05', '51,90'], ['13:38', '75,90'], ['17:06', '87,90'], ['15:06', '127,20'], ['19:06', '127,20']] |
data:
1 | [['07:06' '22,90'] |
2 | ['07:38' '24,90'] |
3 | ['08:38' '24,90'] |
4 | ['21:38' '24,90'] |
5 | ['22:38' '24,90'] |
6 | ['09:38' '26,90'] |
7 | ['10:38' '26,90'] |
8 | ['20:06' '26,90'] |
9 | ['09:06' '39,90'] |
10 | ['10:06' '39,90'] |
11 | ['19:38' '39,90'] |
12 | ['20:38' '39,90'] |
13 | ['13:03' '43,90'] |
14 | ['11:38' '45,90'] |
15 | ['12:06' '45,90'] |
16 | ['12:38' '45,90'] |
17 | ['14:03' '45,90'] |
18 | ['16:38' '45,90'] |
19 | ['17:38' '45,90'] |
20 | ['14:38' '47,90'] |
21 | ['16:03' '49,90'] |
22 | ['18:38' '49,90'] |
23 | ['15:38' '51,90'] |
24 | ['18:05' '51,90'] |
25 | ['13:38' '75,90'] |
26 | ['17:06' '87,90'] |
27 | ['15:06' '127,20'] |
28 | ['19:06' '127,20']] |
1 | plt.bar(datas) |
2 | plt.show() |
oder
1 | plt.bar(data) |
2 | plt.show() |
bringt jeweils den Error: TypeError: bar() missing 1 required positional argument: 'height' am liebsten würde ich gerne direkt datas plotten, da ich diesen einfach mit
1 | datas.sort() |
sortieren kann. Mit data wird mir da alles nur durcheinander gebracht Bsp absatz:
1 | <div class="connectionPrice"> |
2 | <div class="farePep lastrow button-inside tablebutton borderright"><span><span><span class="fareOutput"><span class="farePrefix">ab</span> 12,90 €</span></span></span></div><div class="fareStd button-inside tablebutton center"> |
3 | <span class="button-border "><a class="buttonbold" h r e f="https://reiseauskunft.bahn.de/bin/query.exe/dn?ld=43109&protocol=https:&seqnr=3&ident=a8.07064109.1655184274&rt=1&currentTBPSlot=1&currentTBPConId=A1-0&M=D&E=T&VH=T$A=1@O=Berlin Hbf (tief)@L=8098160@a=0@$A=1@O=Hamburg Hbf@L=8002549@a=0@$202210030706$202210030911$IC 2070$$1$$$$$$&tbpReconstructionMode=out&sTID=A1-0.1&oCID=A1-0&showAvail=yes&completeFulfillment=1&" title="Buchen Sie in den folgenden Schritten Ihre Fahrkarte/Sitzplatzreservierung für Berlin Hbf (tief) - Hamburg Hbf ab 07:06 " ><span></span></a></span> |
4 | </div> |