Personal tools
You are here: Home メンバー 菊地時夫 メモ 高知はまんが王国...かどうかをPythonで確かめる
Document Actions

高知はまんが王国...かどうかをPythonで確かめる

by 菊地時夫 posted at 2007-04-26 10:54 last modified 2007-04-26 10:55

「高知はまんが王国」という伝説がある。本当か?

出身都道府県別漫画家一覧

ウィキペディアの人たちは、よく頑張る。

都道府県別人口

ちょと統計が古いかも。

漫画家の絶対数でいうと、東京が圧倒的に多い。人口も多い。だから、対人口比率で比較してみる。

以下、そのためのプログラム

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
« December 2010 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
About this blog
メモ代わりのブログ
Recent entries
JIS を戻すって tkikuchi 2010-06-14
ゼネラリスト tkikuchi 2010-04-26
Solaris 10 で 64bit tkikuchi 2010-04-11
なんかマヌケ? tkikuchi 2010-02-22
Oracle + ASP.NET なんですね tkikuchi 2010-01-28
Recent comments
Re:lock できないので tkikuchi 2009-06-03
Re:挨拶用メモ tkikuchi 2009-05-27
Re:挨拶用メモ knakahasi 2009-05-04
Re:Xgrid (続編) tkikuchi 2008-10-09
PILでのグラフ出力 ytoshio 2008-03-06
Categories
なんでも
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: