回答編集履歴
2
test
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
import sys
|
6
6
|
|
7
7
|
url = 'https://teratail.com/questions/6su8tx7uey56y2'
|
8
|
-
dfs = pd.read_html(url)
|
8
|
+
dfs = pd.read_html(url) # table 要素に id や class が付与されている場合はそれを利用する
|
9
9
|
|
10
10
|
cols = ['年月', '売上', '単価', '客数']
|
11
11
|
scols = {*cols}
|
1
test
CHANGED
@@ -8,7 +8,8 @@
|
|
8
8
|
dfs = pd.read_html(url)
|
9
9
|
|
10
10
|
cols = ['年月', '売上', '単価', '客数']
|
11
|
+
scols = {*cols}
|
11
|
-
dfs = [df for df in dfs if
|
12
|
+
dfs = [df for df in dfs if scols == {*df.columns}]
|
12
13
|
if not dfs:
|
13
14
|
print('table not found', file=sys.stderr)
|
14
15
|
sys.exit(1)
|