2
내가 (페이 월 뒤에) 테이블을 읽을 전화 read_html 다음() 사용하고 있습니다 : 그것은 마지막 두 개의 열이없는 그것보다 다른, 좋은 구문 분석팬더 read_html()없는 열
df = pd.read_html('http://markets.ft.com/data/equities/tearsheet/' +
'financials?s=BAG:LSE&subView=BalanceSheet&periodType=a')[0]
. 최근 버전의 Anaconda (Python 3.5, pandas 0.18.1, html5lib, BeautifulSoup4)를 사용하고 있습니다.
출력의 시작은 다음과 같습니다
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
되는 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>
끝 의 HTML 모양은 다음과 같습니다.
<tr class="mod-ui-table__row--highlight">
<th class="mod-ui-table__header--row-label">Total liabilities & shareholders' 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>
무엇이 잘못되었을 지 즉시 알 수없는 경우 문제의 원인을 찾기 위해 read_html() 코드를 단계별로 실행하는 방법에 대한 힌트를 주셔서 감사드립니다. 나는 지금 Python/pdb에서 꽤 초보자이다.
그것은 당신이 FT 웹 사이트에 로그인하지 않은 경우, 당신은 데이터 만 3 년을받을 것을 알 수있다. – langbourne