高知はまんが王国...かどうかをPythonで確かめる
「高知はまんが王国」という伝説がある。本当か?
ウィキペディアの人たちは、よく頑張る。
ちょと統計が古いかも。
漫画家の絶対数でいうと、東京が圧倒的に多い。人口も多い。だから、対人口比率で比較してみる。
以下、そのためのプログラム
import re # tag = re.compile(r'<.*?>') # mf = open('mangaka-s.html').read() prfs = mf.split('<h2>') m = [] for i in prfs: try: title, content = i.split('</h2>', 1) title = tag.sub('', title) m.append((title.split()[1], content.count('<li>'))) except: pass del m[0]pf = open('12-01.htm').read() tr = re.compile(r'<tr.*?>') xs = re.compile(r'x:str="(.*?)"') xn = re.compile(r'x:num="(.*?)"') rows = tr.split(pf) p = [] for i in rows: xsm = xs.search(i) xnm = xn.search(i) if xsm and xnm: p.append((''.join(xsm.group(1).split()), int(float(xnm.group(1))*1000))) del p[0] # for i in range(len(p)): assert p[0][0] in m[0][0] print '%10s %3d %4d %5.1f' % (p[i][0], m[i][1], p[i][1]/10000, float(m[i][1])/p[i][1]*1000000)
コメントもないし、いろんなところが決め打ちだし、、、、
これで、あと出力を python manga.py | sort -nr +3 | head
みたいにソートするとトップ10が出てくる。
高知は、人口100万人あたり 40.9 人で、だんとつトップ。 2位は 24.4 人で新潟県。(高橋留美子も新潟県)
ここで、高知県の人口は 80万人しかいないだろうという突っ込みは無し。
実はウィキペディアにバイアスがかかっているということは、あるかもしれない。
- Category(s)
- なんでも
- The URL to Trackback this entry is:
- http://sango.lab.tkikuchi.net/Members/tkikuchi/30e130e2/9ad877e5306f307e3093738b56fd/tbping