2016-12-30 6 views
2

Ich verwende folgende read_html() aufrufen, um eine Tabelle zu lesen (hinter einem paywall):Pandas read_html() fehlt Spalten

df = pd.read_html('http://markets.ft.com/data/equities/tearsheet/' + 
       'financials?s=BAG:LSE&subView=BalanceSheet&periodType=a')[0] 

Es analysiert in Ordnung, außer, dass es die letzten beiden Spalten fehlt. Ich verwende eine neuere Version von Anaconda (Python 3.5, Pandas 0.18.1, HTML5lib, BeautifulSoup4).

Der Start der Ausgabe wie folgt aussieht:

   Fiscal data as of Jan 30 2016 2016 2015 2014 
             ASSETS NaN  NaN  NaN 
      Cash And Short Term Investments 6.80  25  13 
         Total Receivables, Net 50  49  45 
          Total Inventory 16  17  16 

(zu groß, um alles zu zeigen) sieht wie folgt aus

Der Start des HTML:

<table class="mod-ui-table"> 
      <thead> 
       <tr> 
        <th class="mod-ui-table__header--text">Fiscal data as of Jan 30 2016</th> 
        <th>2016</th> 
        <th class="mod-ui-hide-xsmall">2015</th> 
        <th class="mod-ui-hide-xsmall">2014</th> 
        <th class="mod-ui-hide-xsmall">2013</th> 
        <th class="mod-ui-hide-xsmall">2012</th> 
       </tr> 
      </thead> 
      <tr class="mod-ui-table__row--section-header"> 
       <th colspan="6">ASSETS</th> 
      </tr> 
      <tr class="mod-ui-table__row--striped"> 
       <th class="mod-ui-table__header--row-label">Cash And Short Term Investments</th> 
       <td>6.80</td> 
       <td class="mod-ui-hide-xsmall">25</td> 
       <td class="mod-ui-hide-xsmall">13</td> 
       <td class="mod-ui-hide-xsmall">0.91</td> 
       <td class="mod-ui-hide-xsmall">8.29</td> 
      </tr> 
      <tr> 
       <th class="mod-ui-table__header--row-label">Total Receivables, Net</th> 
       <td>50</td> 
       <td class="mod-ui-hide-xsmall">49</td> 
       <td class="mod-ui-hide-xsmall">45</td> 
       <td class="mod-ui-hide-xsmall">42</td> 
       <td class="mod-ui-hide-xsmall">37</td> 
      </tr> 

Das Ende der HTML sieht so aus:

<tr class="mod-ui-table__row--highlight"> 
        <th class="mod-ui-table__header--row-label">Total liabilities &amp; shareholders&#39; equity</th> 
        <td>269</td> 
        <td class="mod-ui-hide-xsmall">255</td> 
        <td class="mod-ui-hide-xsmall">227</td> 
        <td class="mod-ui-hide-xsmall">215</td> 
        <td class="mod-ui-hide-xsmall">196</td> 
       </tr> 
       <tr class="mod-ui-table__row--striped"> 
        <th class="mod-ui-table__header--row-label">Total common shares outstanding</th> 
        <td>117</td> 
        <td class="mod-ui-hide-xsmall">117</td> 
        <td class="mod-ui-hide-xsmall">117</td> 
        <td class="mod-ui-hide-xsmall">117</td> 
        <td class="mod-ui-hide-xsmall">117</td> 
       </tr> 
       <tr> 
        <th class="mod-ui-table__header--row-label">Treasury shares - common primary issue</th> 
        <td>0</td> 
        <td class="mod-ui-hide-xsmall">0</td> 
        <td class="mod-ui-hide-xsmall">0</td> 
        <td class="mod-ui-hide-xsmall">0</td> 
        <td class="mod-ui-hide-xsmall">--</td> 
       </tr> 
      </table> 

Wenn es nicht sofort offensichtlich ist, was falsch ist, bin ich dankbar für einige Hinweise, wie Sie den read_html() - Code durchlaufen können, um die Ursache des Problems zu finden. Ich bin im Moment ziemlich Neuling bei Python/Pdb.

+0

Es stellt sich heraus, dass, wenn Sie nicht in die FT Website angemeldet sind, nur Sie drei Jahren Daten. – langbourne

Antwort

0

Es stellt sich heraus, dass wenn Sie nicht auf der FT-Website angemeldet sind, Sie nur drei Jahre Daten erhalten.

Also gehe ich jetzt vor, um herauszufinden, wie man sich auf der FT-Website anmeldet (vielleicht mit Twill).

Es gibt eine ähnliche Frage here