Data Visualization - World Religions -

各機能をインポートする

In [293]:
%matplotlib inline
import pandas as pd
import numpy as np
import seaborn as sns
from pandas import Series, DataFrame
from matplotlib import pyplot as plt

3つのcsvデータをダウンロードし、読み込み、表示(10行指定)、中身をみる

World Religion Map: https://www.kaggle.com/umichigan/world-religions/downloads/regional.csv/notebook

In [294]:
Global = pd.read_csv('csv/global.csv', index_col=0)
national = pd.read_csv('csv/national.csv', index_col=0)
regional = pd.read_csv('csv/regional.csv', index_col=0)
In [287]:
Global.head(10)
Out[287]:
christianity_protestant christianity_romancatholic christianity_easternorthodox christianity_anglican christianity_other christianity_all judaism_orthodox judaism_conservative judaism_reform judaism_other ... baha’i_percent taoism_percent jainism_percent confucianism_percent syncretism_percent animism_percent noreligion_percent otherreligion_percent religion_sumpercent total_percent
year
1945 160887585 391332035 98501171 36955033 13674466 701350290 856827 1426350 1929388 7796835 ... 0.0000 0.0001 0.0000 0.0000 0.2666 0.0207 0.0955 0.0061 1.012061 0.718667
1950 133301043 401935856 106610911 38307544 16324768 696480122 2204231 1860297 2528641 7105125 ... 0.0003 0.0004 0.0008 0.0012 0.1945 0.0400 0.0869 0.0055 1.011166 0.802432
1955 189347338 474378130 111661338 38177572 22437724 836002102 2496432 1653007 2225241 6611524 ... 0.0003 0.0005 0.0006 0.0012 0.1521 0.0370 0.1199 0.0084 1.011792 0.834366
1960 220293770 541957872 118268109 41846700 44601144 966967595 2818847 1716903 2300405 6892701 ... 0.0004 0.0005 0.0007 0.0012 0.1113 0.0465 0.1488 0.0065 1.013598 0.873137
1965 234437703 614115021 125954494 45086639 55119929 1074713786 3295632 1760345 2348076 6849626 ... 0.0005 0.0005 0.0007 0.0014 0.1094 0.0491 0.1446 0.0126 1.006728 0.884908
1970 247932230 671006540 134595635 46079842 76991429 1176605676 3663721 1923986 2574798 6670904 ... 0.0006 0.0005 0.0007 0.0014 0.1037 0.0457 0.1611 0.0072 1.012190 0.894433
1975 264857729 748325898 137192284 48153338 101587361 1300116609 3910099 2253657 2910930 6839862 ... 0.0006 0.0007 0.0007 0.0013 0.0926 0.0419 0.1716 0.0067 1.012114 0.903261
1980 278962191 798834729 137902427 51093360 125285902 1392078609 4300992 2439116 3153787 6713100 ... 0.0008 0.0009 0.0008 0.0013 0.0934 0.0388 0.1730 0.0082 0.977425 0.909855
1985 305061321 865316946 141435053 56651880 138453851 1506919051 4580474 2466942 3320124 6415455 ... 0.0007 0.0010 0.0008 0.0003 0.0933 0.0356 0.1688 0.0078 0.976472 0.915925
1990 391772588 928527756 147970918 63954053 162855904 1695081219 4395315 1926083 2458253 6089896 ... 0.0010 0.0011 0.0007 0.0002 0.0883 0.0343 0.1578 0.0068 1.009826 0.934234

10 rows × 75 columns

In [288]:
regional.head(10)
Out[288]:
region christianity_protestant christianity_romancatholic christianity_easternorthodox christianity_anglican christianity_other christianity_all judaism_orthodox judaism_conservative judaism_reform ... taoism_percent jainism_percent confucianism_percent syncretism_percent animism_percent noreligion_percent otherreligion_percent religion_sumpercent total_percent worldpopulation_percent
year
1945 Africa 2074180 672337 7251492 419457 4170594 14588060 0 0 0 ... 0.0000 0.0000 0.000 0.0000 0.3151 0.0003 0.0014 0.9997 1.0000 0.0180
1945 Asia 2407144 2222908 181928 3142204 1964907 9919091 0 0 0 ... 0.0002 0.0000 0.000 0.6378 0.0340 0.0462 0.0002 1.0043 1.0505 0.4103
1945 Europe 83145512 216041422 86503645 29855595 5361826 420908000 0 0 0 ... 0.0000 0.0000 0.000 0.0000 0.0023 0.1780 0.0045 0.8220 1.0000 0.3468
1945 Mideast 87174 635929 3180260 0 108332 4011695 0 0 0 ... 0.0000 0.0000 0.000 0.0000 0.0000 0.0000 0.0073 1.0000 1.0000 0.0403
1945 West. Hem 73173575 171759439 1383846 3537777 2068807 251923444 856827 1426350 1929388 ... 0.0000 0.0000 0.000 0.0190 0.0008 0.0795 0.0230 0.9377 1.0172 0.1790
1950 Africa 3302860 736193 7260770 609769 4884121 16793713 0 0 0 ... 0.0000 0.0000 0.000 0.0000 0.3288 0.0006 0.0001 0.9994 1.0000 0.0151
1950 Asia 9360004 25948053 1051829 3612715 5190796 45163397 0 0 0 ... 0.0007 0.0014 0.002 0.3274 0.0585 0.0532 0.0004 0.9791 1.0324 0.5828
1950 Europe 40293475 182146023 91004796 29739026 4534844 347718164 0 0 0 ... 0.0000 0.0000 0.000 0.0000 0.0025 0.2071 0.0011 0.7929 1.0000 0.2181
1950 Mideast 27091 946089 4047536 0 93138 5113854 1090162 6607 4404 ... 0.0000 0.0000 0.000 0.0000 0.0000 0.0000 0.0180 1.0000 1.0000 0.0348
1950 West. Hem 80317613 192159498 3245980 4346034 1621869 281690994 1114069 1853690 2524237 ... 0.0000 0.0000 0.000 0.0194 0.0014 0.0711 0.0302 0.9456 1.0168 0.1445

10 rows × 77 columns

In [289]:
national.head(10)
Out[289]:
year state buddhism_all shinto_all religion_all population
0 1945 United States of America 1601218 0 139382062 139928000
1 1950 United States of America 0 0 151652986 152271008
2 1955 United States of America 90173 0 162728815 165931000
3 1960 United States of America 2012131 0 179294703 180671000
4 1965 United States of America 1080892 0 194049012 194631000
5 1970 United States of America 1113861 0 200695751 200706000
6 1975 United States of America 1019556 0 215701628 215943000
7 1980 United States of America 1357967 0 225891446 227726000
8 1985 United States of America 1984325 0 238168864 238466000
9 1990 United States of America 1575481 59724 249744836 249907000

ランダムに中身を表示する

アメリカ以外の国も含まれていることがわかる

In [295]:
national.sample(10)
Out[295]:
state code christianity_protestant christianity_romancatholic christianity_easternorthodox christianity_anglican christianity_other christianity_all judaism_orthodox judaism_conservative ... jainism_percent confucianism_percent syncretism_percent animism_percent noreligion_percent otherreligion_percent religion_sumpercent total_percent dual_religion source_code
year
2005 Philippines PHI 4212050 68235208 0 135000 4001910 76584168 0 0 ... 0.0 0.0 0.0006 0.0235 0.0091 0.0036 0.9964 1.0000 0 99
1975 Ethiopia ETH 867513 131596 12419843 2980 1960744 15382676 0 0 ... 0.0 0.0 0.0000 0.1300 0.0001 0.0009 0.9991 1.0001 0 99
1985 Equatorial Guinea EQG 15050 269520 0 0 0 284570 0 0 ... 0.0 0.0 0.0000 0.0394 0.0200 0.0112 0.9888 1.0000 0 1
1970 United States of America USA 93918347 69119143 5498914 3030647 1300000 172867051 1088550 1808100 ... 0.0 0.0 0.0000 0.0000 0.1020 0.0001 0.9999 0.9999 0 7
1990 Mongolia MON 17310 250 1600 0 3327 22487 0 0 ... 0.0 0.0 0.0039 0.2100 0.3162 0.0008 0.9992 0.9999 0 7
1950 New Zealand NEW 654000 280000 2003 690000 233590 1859593 0 0 ... 0.0 0.0 0.0026 0.0038 0.0149 0.0008 0.9992 1.0000 0 7
1965 Myanmar MYA 1065926 242180 0 28685 0 1336791 0 0 ... 0.0 0.0 0.0031 0.1198 0.0026 0.0005 0.9995 1.0000 1 20
2005 Tunisia TUN 0 20000 0 0 5000 25000 0 0 ... 0.0 0.0 0.0000 0.0000 0.0000 0.0073 0.9927 1.0000 0 83
1980 Cape Verde CAP 8600 275280 0 0 5920 289800 0 0 ... 0.0 0.0 0.0000 0.0080 0.0074 0.0048 0.9952 1.0000 0 7
1965 Sweden SWD 7371210 35500 0 0 0 7406710 0 0 ... 0.0 0.0 0.0000 0.0000 0.0400 0.0004 0.9996 1.0000 0 99

10 rows × 78 columns

csvの国数を表示する

国名でグループすることにより、複数の国名を1つにし、count()で各行を数える

In [196]:
national.groupby(['state']).size().count()
Out[196]:
200

csvの国名を表示する

In [303]:
print(national['state'].unique())
['United States of America' 'Canada' 'Bahamas' 'Cuba' 'Haiti'
 'Dominican Republic' 'Jamaica' 'Trinidad and Tobago' 'Barbados'
 'Dominica' 'Grenada' 'St. Lucia' 'St. Vincent and the Grenadines'
 'Antigua & Barbuda' 'St. Kitts and Nevis' 'Mexico' 'Belize' 'Guatemala'
 'Honduras' 'El Salvador' 'Nicaragua' 'Costa Rica' 'Panama' 'Colombia'
 'Venezuela' 'Guyana' 'Suriname' 'Ecuador' 'Peru' 'Brazil' 'Bolivia'
 'Paraguay' 'Chile' 'Argentina' 'Uruguay' 'United Kingdom' 'Ireland'
 'Netherlands' 'Belgium' 'Luxembourg' 'France' 'Monaco' 'Liechtenstein'
 'Switzerland' 'Spain' 'Andorra' 'Portugal' 'Germany'
 'German Federal Republic' 'German Democratic Republic' 'Poland' 'Austria'
 'Hungary' 'Czechoslovakia' 'Czech Republic' 'Slovakia' 'Italy'
 'San Marino' 'Malta' 'Albania' 'Montenegro' 'Macedonia' 'Croatia'
 'Yugoslavia' 'Bosnia and Herzegovina' 'Kosovo' 'Slovenia' 'Greece'
 'Cyprus' 'Bulgaria' 'Moldova' 'Romania' 'Russia' 'Estonia' 'Latvia'
 'Lithuania' 'Ukraine' 'Belarus' 'Armenia' 'Georgia' 'Azerbaijan'
 'Finland' 'Sweden' 'Norway' 'Denmark' 'Iceland' 'Cape Verde'
 'Sao Tome and Principe' 'Guinea-Bissau' 'Equatorial Guinea' 'Gambia'
 'Mali' 'Senegal' 'Benin' 'Mauritania' 'Niger' 'Ivory Coast' 'Guinea'
 'Burkina Faso' 'Liberia' 'Sierra Leone' 'Ghana' 'Togo' 'Cameroon'
 'Nigeria' 'Gabon' 'Central African Republic' 'Chad' 'Congo'
 'Democratic Republic of the Congo' 'Uganda' 'Kenya' 'Tanzania' 'Burundi'
 'Rwanda' 'Somalia' 'Djibouti' 'Ethiopia' 'Eritrea' 'Angola' 'Mozambique'
 'Zambia' 'Zimbabwe' 'Malawi' 'South Africa' 'Namibia' 'Lesotho'
 'Botswana' 'Swaziland' 'Madagascar' 'Comoros' 'Mauritius' 'Seychelles'
 'Morocco' 'Algeria' 'Tunisia' 'Libya' 'Sudan' 'Iran' 'Turkey' 'Iraq'
 'Egypt' 'Syria' 'Lebanon' 'Jordan' 'Israel' 'Saudi Arabia'
 'Yemen Arab Republic' 'Yemen' "Yemen People's Republic" 'Kuwait'
 'Bahrain' 'Qatar' 'United Arab Emirates' 'Oman' 'Afghanistan'
 'Turkmenistan' 'Tajikistan' 'Kyrgyzstan' 'Uzbekistan' 'Kazakhstan'
 'China' 'Mongolia' 'Taiwan' 'North Korea' 'South Korea' 'Japan' 'India'
 'Bhutan' 'Pakistan' 'Bangladesh' 'Myanmar' 'Sri Lanka' 'Maldives' 'Nepal'
 'Thailand' 'Cambodia' 'Laos' 'Vietnam' 'Republic of Vietnam' 'Malaysia'
 'Singapore' 'Brunei' 'Philippines' 'Indonesia' 'East Timor' 'Australia'
 'Papua New Guinea' 'New Zealand' 'Vanuatu' 'Solomon Islands' 'Kiribati'
 'Tuvalu' 'Fiji' 'Tonga' 'Nauru' 'Marshall Islands' 'Palau'
 'Federated States of Micronesia' 'Samoa']

年代別世界の神道人口

In [152]:
Global.shinto_all.plot(kind='bar', title='世界の神道人口/年代', rot=45)
Out[152]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d91262e8>

世界人口からみる神道信者数

In [153]:
(Global['shinto_all'] / Global['world_population']).plot('bar', title='世界人口からみる神道信者数')
Out[153]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d90a0048>

読み込みで列の指定

In [281]:
national = pd.read_csv('csv/national.csv',
                 usecols=[0, 1,25,29,38,39,76],    # 使う列は 1,25,29,38,39,76列
                 index_col=1)      # indexはstateに
national.head(3)
Out[281]:
year buddhism_all shinto_all religion_all population total_percent
state
United States of America 1945 1601218 0 139382062 139928000 1.0000
United States of America 1950 0 0 151652986 152271008 1.0000
United States of America 1955 90173 0 162728815 165931000 0.9999

列の指定

In [155]:
national.head(3)[['year', 'religion_all']]
Out[155]:
year religion_all
state
United States of America 1945 139382062
United States of America 1950 151652986
United States of America 1955 162728815

行の指定

In [156]:
national['Japan':'Japan']
Out[156]:
year buddhism_all shinto_all religion_all population total_percent
state
Japan 1945 49081430 55228775 105659957 72147000 1.4646
Japan 1950 59852100 65452839 127578439 85503000 1.4922
Japan 1955 62014000 68145114 134712557 89020000 1.5133
Japan 1960 65251200 71357167 145918694 93216000 1.5654
Japan 1965 68566400 74982591 155161247 97952000 1.5840
Japan 1970 72382100 79155350 165664094 103403000 1.6021
Japan 1975 79016830 85409513 179271021 111573000 1.6068
Japan 1980 85269110 89416158 190641464 116807000 1.6321
Japan 1985 90127750 92501136 198672736 120837000 1.6442
Japan 1990 92138500 94522831 203124753 123478000 1.6451
Japan 1995 92849280 96049245 207686325 125472000 1.6552
Japan 2000 83732611 97000000 198519333 126714000 1.5667
Japan 2005 89000000 107000000 214983033 127773000 1.6825
Japan 2010 88035713 108000000 211308623 127451704 1.6578

列と行の指定

.loc['インデックスの行','列']

In [282]:
national.loc['Japan','religion_all']
Out[282]:
state
Japan    105659957
Japan    127578439
Japan    134712557
Japan    145918694
Japan    155161247
Japan    165664094
Japan    179271021
Japan    190641464
Japan    198672736
Japan    203124753
Japan    207686325
Japan    198519333
Japan    214983033
Japan    211308623
Name: religion_all, dtype: int64

日本における全宗教人口と神道+仏教人口との割合

In [158]:
df_jp = (national.loc['Japan','shinto_all'] + national.loc['Japan','buddhism_all'] / national.loc['Japan','religion_all']).sort_values(ascending=False)
df_jp.plot('bar', title='日本における全宗教人口と神道+仏教人口との割合', rot=45)
Out[158]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d9116da0>

インデックスを国名にして日本を摘出したことにより、インデックスに年代が表示できない

列と行の中の項目を指定することはできないのだろうか....

先生のアドバイスにより、以下のように解説

日本における全宗教人口と神道+仏教人口との割合 (解決版)

日本をloc(行ラベル)で指定し、df_jpに代入し、インデックスをset_index()で設定し、年代を指定

In [159]:
df_jp = national.loc['Japan']
df_jp = df_jp.set_index('year')
df_jp['shinto_and_buddhism_ratio'] = df_jp['shinto_all'] + df_jp['buddhism_all'] / df_jp['religion_all']
df_jp['shinto_and_buddhism_ratio'].plot('bar', title='日本における全宗教人口と神道+仏教人口との割合', rot=45)
Out[159]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d8f30e10>

2005年から他の宗教より神道+仏教人口が上回っていることがわかる

日本における神道+仏教人口の増加 (解決版)

日本の人口から神道+仏教人口を割って比率でみることで、人口増加の要因から離れてみることができる

In [49]:
df_jp = national.loc['Japan']
df_jp = df_jp.set_index('year')
df_jp['shinto_and_buddhism_ratio'] = df_jp['shinto_all'] + df_jp['buddhism_all'] / df_jp['population']
df_jp['shinto_and_buddhism_ratio'].plot('bar', title='日本における全宗教人口と神道+仏教人口との割合', rot=45)
Out[49]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa573038f28>

神道+仏教人口が、2005年から人口より上回っている。

神道が文化に溶け込んでいる日本では、神道+他の宗教を支持する人が多いということだろうか。

では、人口数が宗教人口より上回っている国は他にもあるのだろうか...

人口数が宗教人口より上回っている国

In [161]:
national['total_percent'].sort_values(ascending=False)
Out[161]:
state
Cuba                                1.7277
Cuba                                1.6960
Cuba                                1.6938
Cuba                                1.6894
Cuba                                1.6890
Cuba                                1.6877
Cuba                                1.6851
Japan                               1.6825
Cuba                                1.6805
Japan                               1.6578
Japan                               1.6552
Haiti                               1.6515
Japan                               1.6451
Japan                               1.6442
Cuba                                1.6413
Japan                               1.6321
Haiti                               1.6172
Japan                               1.6068
Japan                               1.6021
Cuba                                1.5882
Japan                               1.5840
Cuba                                1.5740
Cuba                                1.5710
Japan                               1.5667
Japan                               1.5654
Japan                               1.5133
Japan                               1.4922
Haiti                               1.4806
Haiti                               1.4786
Haiti                               1.4655
                                     ...  
Zimbabwe                            0.9998
Nigeria                             0.9998
Argentina                           0.9998
Peru                                0.9998
Laos                                0.9998
Kenya                               0.9998
China                               0.9998
Iceland                             0.9998
Turkey                              0.9998
Tajikistan                          0.9998
Malaysia                            0.9998
Paraguay                            0.9998
Trinidad and Tobago                 0.9998
Thailand                            0.9998
Democratic Republic of the Congo    0.9998
Malawi                              0.9998
Norway                              0.9998
Australia                           0.9998
United Kingdom                      0.9998
Cameroon                            0.9998
Malawi                              0.9998
Ireland                             0.9998
Nepal                               0.9998
Kenya                               0.9998
South Korea                         0.9998
Kenya                               0.9998
Sri Lanka                           0.9998
South Africa                        0.9998
Sri Lanka                           0.9998
Pakistan                            0.9998
Name: total_percent, Length: 1995, dtype: float64

神道人口数をどう計算したのかは不明だが、日本以外でもCuba、Haitiがあるよう。

国別神道の年代人口ヒートマップ

TIP: index_col=1を指定するとIndex部を読み込めなくエラーが出るので、削除すること

In [300]:
national = pd.read_csv('csv/national.csv', usecols=[0, 1,25,29,38,39])
plt.figure(figsize=(27, 8))
sns.heatmap(national.pivot('year', 'state', 'shinto_all'), cmap='Blues')
Out[300]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa56da8af28>

神道は日本のみで栄えていることがわかる

国別仏教の年代人口ヒートマップ

In [301]:
plt.figure(figsize=(27, 8))
sns.heatmap(national.pivot('year', 'state', 'buddhism_all'), cmap='Greens')
Out[301]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa56da8a4e0>

国別だと200の国名が表示できなく、国を特定できないが日本以外でも仏教徒がいることがわかる

エリア別神道の年代人口ヒートマップ

In [163]:
regional = pd.read_csv('csv/regional.csv')
sns.heatmap(regional.pivot('year', 'region', 'shinto_all'), cmap='Blues')
Out[163]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d8da1278>

神道人口はアジア(日本のみ)で年々急増している > 人口増加による急増

エリア別仏教の年代人口ヒートマップ

In [176]:
sns.heatmap(regional.pivot('year', 'region', 'buddhism_all'), cmap='Greens')
Out[176]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdb2d1a0908>

仏教人口はアジアのみで年々急増している > 人口増加による急増

日本における神道の年代人口

In [139]:
national = pd.read_csv('csv/national.csv', usecols=[0, 1,25,29,38,39])
sns.barplot(x= national.year, y= national[national.state=='Japan']['shinto_all'],palette= 'Blues')
Out[139]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d933ba58>

日本における仏教の年代人口

In [140]:
national = pd.read_csv('csv/national.csv', usecols=[0, 1,25,29,38,39])
sns.barplot(x= national.year, y= national[national.state=='Japan']['buddhism_all'],palette= 'Greens')
Out[140]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f17d940d0f0>

エリア別世界人口ヒートマップ

In [182]:
sns.heatmap(regional.pivot('year', 'region', 'world_population'), cmap='Reds')
Out[182]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdb2cfc8cf8>

世界全体で人口が増加していることがわかる

エリア別宗教人口ヒートマップ

In [184]:
sns.heatmap(regional.pivot('year', 'region', 'religion_all'), cmap='Reds')
Out[184]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdb2cd2b940>

宗教人口はなぜかアジアだけ増加していることがわかる

世界の宗教別人口数

In [93]:
Global = pd.read_csv('csv/global.csv')
cols= ['year','christianity_all','islam_all','hinduism_all','buddhism_all','noreligion_all','syncretism_all','christianity_percent','hinduism_percent','islam_percent','buddhism_percent','syncretism_percent','noreligion_percent']
Global= Global[cols]

for col in Global.columns:
    if '_all' in col:
        ax= plt.plot(Global.index, Global[col],label= col, linewidth= 3)
        plt.title('宗教別支持者数')
        plt.legend(bbox_to_anchor= (-.2,-.5,1.4,.5), mode= 'expand', loc=3,ncol=3,fontsize= 14)
        plt.xticks(size=14)
        plt.yticks(size=14)

クリスチャンが多く、人口増加で右上がり

世界の宗教相対関係

In [190]:
Global = pd.read_csv('csv/global.csv')
cols= ['christianity_all','islam_all','hinduism_all','buddhism_all','shinto_all','noreligion_all','syncretism_all']
Global= Global[cols]
plt.figure(figsize=(13, 11))
sns.heatmap(Global.corr(), square=True,  cmap='Blues', annot=True, fmt="1.1f")
plt.title('世界の宗教相対関係')
Out[190]:
Text(0.5, 1, '世界の宗教相対関係')

4大宗教のキリスト教、イスラム教、ヒンデゥー教、仏教の相対値が濃くなっている。

シンクレティズム(syncretism)は、重層信仰という意味で、日本の神仏習合(神道+仏教)の現れだが、色の変化はイスラム教より顕著でない。

世界の宗教相対関係 ver.2

人口、宗教人口、他の宗教も追加

In [191]:
Global = pd.read_csv('csv/global.csv')
cols= ['population','religion_all','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']
Global= Global[cols]
plt.figure(figsize=(13, 11))
sns.heatmap(Global.corr(), square=True,  cmap='Blues', annot=True, fmt="1.1f")
plt.title('世界の宗教相対関係 ver.2')
Out[191]:
Text(0.5, 1, '世界の宗教相対関係 ver.2')

世界の宗教相対関係 ver.3

他の記述方法

In [205]:
cols = Global.corr()
order =  ['population','religion_all','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']
cols[order]
cols_ordered = cols[order]
plt.figure(figsize=(13, 11))
sns.heatmap(cols_ordered, square=True,  cmap='Blues', annot=True, fmt="1.1f")
plt.title('世界の宗教相対関係 ver.3')
Out[205]:
Text(0.5, 1, '世界の宗教相対関係 ver.3')

世界の宗教別人口

In [276]:
regional= pd.read_csv('csv/regional.csv')
cols= ['year','population','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']
regionals= regional[cols]
regionals
Out[276]:
year population christianity_all judaism_all islam_all hinduism_all buddhism_all shinto_all zoroastrianism_all sikhism_all baha’i_all jainism_all animism_all noreligion_all syncretism_all
0 1945 29073000 14588060 80487 5051475 137290 53 0 0 1536 2021 0 9162018 7396 831
1 1945 663450000 9919091 30369 36260345 5230216 113681431 55228775 2710 12525 7243 0 22525760 30637661 423153390
2 1945 560750000 420908000 6068020 29353397 21691 725632 0 0 1748 6231 181 1294177 99829250 5896
3 1945 65219000 4011695 623240 60095064 0 0 0 10000 0 0 0 0 561 0
4 1945 289375655 251923444 5207284 0 0 1830820 0 0 5000 0 0 228125 23011662 5500000
5 1950 33707000 16793713 97006 5508523 195524 194 0 0 1943 3004 0 11084152 19918 973
6 1950 1300208016 45163397 54754 189121761 301106975 158063522 65452839 114462 5910591 453734 1816754 76081638 69193934 425681485
7 1950 486520000 347718164 5336066 30109208 44995 759624 0 0 10022 8041 500 1238087 100773236 9763
8 1950 77683000 5113854 1630211 69360805 0 0 0 5000 0 172960 0 0 0 0
9 1950 322455008 281690994 6580257 20770 2006 188562 0 0 10001 1000 0 450003 22938228 6249873
10 1955 34925000 18937318 117741 6002686 278538 707 0 0 2457 7593 0 9419390 53634 1139
11 1955 1436233000 58967413 81070 210722747 328331380 177963621 68145114 126582 6342714 738141 1619287 82851650 161895190 378770746
12 1955 603716000 441172436 5178671 33390170 93684 806776 0 0 57446 15068 1375 1189903 118537427 26391
13 1955 102730000 5654101 1966399 93953674 0 0 0 14180 0 0 0 0 270 5588
14 1955 358220000 311270834 5642323 2730 1003 613095 0 0 5000 500 0 250001 23641928 6898286
15 1960 148806000 61557803 138994 42908236 363925 3416 0 0 2971 157462 0 42355767 265053 4646
16 1960 1594029976 74184616 80005 240171009 360471285 196663980 71357167 170443 7980296 899468 2029510 89171314 278617080 317448262
17 1960 639466000 458326158 5068023 35477503 142373 853421 0 0 104871 21419 2250 1141720 133709658 37975
18 1960 128887000 5473940 2135285 116514804 0 0 0 0 0 200000 0 2800000 277 0
19 1960 409598148 367425078 6306549 51536 191584 2918342 0 0 0 0 0 300000 22037603 7525200
20 1965 219965000 98101226 147929 56667388 548874 4572 0 324 25853 557883 28913 61942649 354423 14203
21 1965 1772609960 85484649 79304 275213701 396909711 209671102 74982591 138682 8717537 1046723 2309710 94583167 305127190 350788060
22 1965 676315000 476176756 4983768 36814738 191110 900068 0 0 152295 28308 3125 1093535 147965351 49559
23 1965 159755000 6054509 2625113 145848262 0 0 0 9938 0 17627 0 2995006 47680 0
24 1965 450956507 408896646 6417565 89968 213487 2017642 0 0 0 8350 0 279349 20603206 7993000
25 1970 255537000 122086968 151537 66818285 991566 11299 0 472 26094 701507 32861 63335604 446303 17679
26 1970 2013375984 102736795 78269 318451549 448086953 226489880 79155350 106789 10441204 1177687 2590921 98686228 398889032 370782297
27 1970 703129248 488279742 4883835 38264883 242896 955963 0 410 199719 49039 4000 1047415 162011668 62146
28 1970 184476000 8264204 2584234 168490055 7470 0 0 0 0 96033 0 3326100 153410 0
29 1970 498934000 455237967 7135534 317516 495604 1345492 1000 0 19615 270712 980 613877 27337768 8294607
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
40 1985 432444000 228658879 164828 125892684 1463736 72574 0 607 37537 1074228 49895 69685451 2149016 43652
41 1985 2525823952 175024514 100490 313273334 598009426 334462502 92520741 262761 14651868 1978767 3508357 90948268 542261654 425483823
42 1985 769476405 496457481 4364409 42150125 474973 1086688 0 523 217500 72559 9648 713756 210577941 89957
43 1985 285529000 11187498 3630574 262830380 82000 35000 0 0 15000 7950 0 4265733 22000 9000
44 1985 655792000 595590679 8522694 2982068 1592400 2013925 0 0 0 46920 0 453731 33185698 10002600
45 1990 483823000 265493449 142152 135413988 1762136 100263 0 720 44358 1150689 57010 73843670 2896489 57936
46 1990 2937844992 222571100 104493 508795898 656018252 371399010 94546096 314540 18621706 2301416 3809813 103439157 561364124 459167251
47 1990 845942719 547627544 4094416 43630843 545390 1260132 0 610 228000 100313 11531 970327 236076477 243791
48 1990 337954000 16072151 3746388 308955332 318199 114686 0 500030 48899 224304 0 3276509 1641499 28966
49 1990 707106969 643316975 6782098 2884257 1205851 2373664 61724 62501 258517 1288261 6410 652668 36292691 9701954
50 1995 565658000 314790124 121360 163595753 1317227 66300 0 782 40993 1246159 61627 74918182 5092209 48635
51 1995 3228425512 259779112 195111 606168389 717365785 408209553 96076062 247242 18492938 2435313 4014448 112240465 574222830 492135244
52 1995 745952000 512007252 2565349 41542293 699215 1497063 0 731 294718 129783 13413 1232015 176181859 302461
53 1995 374116000 17023562 4638374 340695671 4791 0 0 472500 1166 278675 0 3534249 323129 0
54 1995 754990021 681814919 6552112 2988500 1481887 2182414 60945 765727 245269 757649 6684 981414 46460699 10533280
55 2000 618965000 336756649 104482 188503322 1902086 142869 0 845 53080 1083236 69013 78607573 5809663 77232
56 2000 3488405040 256892044 148450 697689629 870077984 381710232 97027500 84816 19356059 2148598 4231099 77705808 584748329 549045116
57 2000 745596883 571107445 2243767 47729841 764336 3099355 0 4782 396383 77628 15296 78139 113729094 129943
58 2000 409782300 16678853 4956077 376076983 1141268 88823 0 445000 15420 142471 0 5898000 1775785 0
59 2000 823033224 709488193 5993536 4048465 1720060 3214777 161765 1468955 232021 628141 6959 4457945 76349251 13592264
60 2005 703623000 397001958 105776 213125720 2118924 182161 0 838 61177 1082939 73053 79035014 7178005 84834
61 2005 3666155352 275275093 127286 749421842 940599251 466101118 107029655 91049 20940691 2306979 4574392 79217233 524304023 555845044
62 2005 744761600 559337643 2123463 51230517 996551 3059535 0 5105 412726 61087 17648 186360 114977698 426992
63 2005 445958853 18237497 5309425 408154695 1454979 105908 0 19500 17500 152950 0 7079400 2652435 0
64 2005 875196370 740879276 6604378 4521572 2191657 4668399 191600 1559581 437055 705878 79864 5830711 94709150 12979998
65 2010 799492401 460005841 106121 246404472 2347387 224181 0 951 74969 1183246 91857 77615288 8889456 97374
66 2010 3857553138 287921863 123356 804756836 1008830303 478920926 108029951 94666 22509620 2580737 4915980 81146609 541453380 578913544
67 2010 754067657 557677984 1378063 51222711 1125071 1556416 0 4404 490470 48120 20000 232716 130820732 548795
68 2010 491293037 19813797 5604499 448620067 2284384 142503 0 0 19000 362367 0 8025046 3612800 0
69 2010 928209348 786493468 6811270 4478680 2755503 4402911 313241 1651017 682441 665592 87304 7244680 103547575 10970832

70 rows × 15 columns

世界における無宗教人口の割合の変化(ver.1)

In [211]:
regional = pd.read_csv('csv/regional.csv')
plt.figure(figsize=(13, 8))
sns.heatmap(regional.pivot('region', 'year', 'noreligion_all'), cmap='Purples')
Out[211]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa56e027dd8>

アジアで急激に無宗教人口が多くなっている

世界における無宗教人口の割合の変化(ver.2)

In [306]:
colormap = plt.cm.Set2
noreligion_year = regional.groupby(['year','region']).noreligion_all.sum()
noreligion_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, figsize=(14,8) , 
                               legend=False, title='無宗教人口の割合の変化')
plt.legend(bbox_to_anchor= (-.2,-.6,1.4,.5), mode= 'expand', loc=1, ncol=5, fontsize= 14)
plt.show()

アジア(青)が一番、無宗教人口が増えている

複数の列を代入 (ver.1)

[cols]の中身は[['region'....'syncretism_all']]として[ ]も含めて代入されるため、Dataframeになる

In [311]:
cols= ['year','region','population','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']
regionals= regional[cols]
regionals
Out[311]:
year region population christianity_all judaism_all islam_all hinduism_all buddhism_all shinto_all zoroastrianism_all sikhism_all baha’i_all jainism_all animism_all noreligion_all syncretism_all
0 1945 Africa 29073000 14588060 80487 5051475 137290 53 0 0 1536 2021 0 9162018 7396 831
1 1945 Asia 663450000 9919091 30369 36260345 5230216 113681431 55228775 2710 12525 7243 0 22525760 30637661 423153390
2 1945 Europe 560750000 420908000 6068020 29353397 21691 725632 0 0 1748 6231 181 1294177 99829250 5896
3 1945 Mideast 65219000 4011695 623240 60095064 0 0 0 10000 0 0 0 0 561 0
4 1945 West. Hem 289375655 251923444 5207284 0 0 1830820 0 0 5000 0 0 228125 23011662 5500000
5 1950 Africa 33707000 16793713 97006 5508523 195524 194 0 0 1943 3004 0 11084152 19918 973
6 1950 Asia 1300208016 45163397 54754 189121761 301106975 158063522 65452839 114462 5910591 453734 1816754 76081638 69193934 425681485
7 1950 Europe 486520000 347718164 5336066 30109208 44995 759624 0 0 10022 8041 500 1238087 100773236 9763
8 1950 Mideast 77683000 5113854 1630211 69360805 0 0 0 5000 0 172960 0 0 0 0
9 1950 West. Hem 322455008 281690994 6580257 20770 2006 188562 0 0 10001 1000 0 450003 22938228 6249873
10 1955 Africa 34925000 18937318 117741 6002686 278538 707 0 0 2457 7593 0 9419390 53634 1139
11 1955 Asia 1436233000 58967413 81070 210722747 328331380 177963621 68145114 126582 6342714 738141 1619287 82851650 161895190 378770746
12 1955 Europe 603716000 441172436 5178671 33390170 93684 806776 0 0 57446 15068 1375 1189903 118537427 26391
13 1955 Mideast 102730000 5654101 1966399 93953674 0 0 0 14180 0 0 0 0 270 5588
14 1955 West. Hem 358220000 311270834 5642323 2730 1003 613095 0 0 5000 500 0 250001 23641928 6898286
15 1960 Africa 148806000 61557803 138994 42908236 363925 3416 0 0 2971 157462 0 42355767 265053 4646
16 1960 Asia 1594029976 74184616 80005 240171009 360471285 196663980 71357167 170443 7980296 899468 2029510 89171314 278617080 317448262
17 1960 Europe 639466000 458326158 5068023 35477503 142373 853421 0 0 104871 21419 2250 1141720 133709658 37975
18 1960 Mideast 128887000 5473940 2135285 116514804 0 0 0 0 0 200000 0 2800000 277 0
19 1960 West. Hem 409598148 367425078 6306549 51536 191584 2918342 0 0 0 0 0 300000 22037603 7525200
20 1965 Africa 219965000 98101226 147929 56667388 548874 4572 0 324 25853 557883 28913 61942649 354423 14203
21 1965 Asia 1772609960 85484649 79304 275213701 396909711 209671102 74982591 138682 8717537 1046723 2309710 94583167 305127190 350788060
22 1965 Europe 676315000 476176756 4983768 36814738 191110 900068 0 0 152295 28308 3125 1093535 147965351 49559
23 1965 Mideast 159755000 6054509 2625113 145848262 0 0 0 9938 0 17627 0 2995006 47680 0
24 1965 West. Hem 450956507 408896646 6417565 89968 213487 2017642 0 0 0 8350 0 279349 20603206 7993000
25 1970 Africa 255537000 122086968 151537 66818285 991566 11299 0 472 26094 701507 32861 63335604 446303 17679
26 1970 Asia 2013375984 102736795 78269 318451549 448086953 226489880 79155350 106789 10441204 1177687 2590921 98686228 398889032 370782297
27 1970 Europe 703129248 488279742 4883835 38264883 242896 955963 0 410 199719 49039 4000 1047415 162011668 62146
28 1970 Mideast 184476000 8264204 2584234 168490055 7470 0 0 0 0 96033 0 3326100 153410 0
29 1970 West. Hem 498934000 455237967 7135534 317516 495604 1345492 1000 0 19615 270712 980 613877 27337768 8294607
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
40 1985 Africa 432444000 228658879 164828 125892684 1463736 72574 0 607 37537 1074228 49895 69685451 2149016 43652
41 1985 Asia 2525823952 175024514 100490 313273334 598009426 334462502 92520741 262761 14651868 1978767 3508357 90948268 542261654 425483823
42 1985 Europe 769476405 496457481 4364409 42150125 474973 1086688 0 523 217500 72559 9648 713756 210577941 89957
43 1985 Mideast 285529000 11187498 3630574 262830380 82000 35000 0 0 15000 7950 0 4265733 22000 9000
44 1985 West. Hem 655792000 595590679 8522694 2982068 1592400 2013925 0 0 0 46920 0 453731 33185698 10002600
45 1990 Africa 483823000 265493449 142152 135413988 1762136 100263 0 720 44358 1150689 57010 73843670 2896489 57936
46 1990 Asia 2937844992 222571100 104493 508795898 656018252 371399010 94546096 314540 18621706 2301416 3809813 103439157 561364124 459167251
47 1990 Europe 845942719 547627544 4094416 43630843 545390 1260132 0 610 228000 100313 11531 970327 236076477 243791
48 1990 Mideast 337954000 16072151 3746388 308955332 318199 114686 0 500030 48899 224304 0 3276509 1641499 28966
49 1990 West. Hem 707106969 643316975 6782098 2884257 1205851 2373664 61724 62501 258517 1288261 6410 652668 36292691 9701954
50 1995 Africa 565658000 314790124 121360 163595753 1317227 66300 0 782 40993 1246159 61627 74918182 5092209 48635
51 1995 Asia 3228425512 259779112 195111 606168389 717365785 408209553 96076062 247242 18492938 2435313 4014448 112240465 574222830 492135244
52 1995 Europe 745952000 512007252 2565349 41542293 699215 1497063 0 731 294718 129783 13413 1232015 176181859 302461
53 1995 Mideast 374116000 17023562 4638374 340695671 4791 0 0 472500 1166 278675 0 3534249 323129 0
54 1995 West. Hem 754990021 681814919 6552112 2988500 1481887 2182414 60945 765727 245269 757649 6684 981414 46460699 10533280
55 2000 Africa 618965000 336756649 104482 188503322 1902086 142869 0 845 53080 1083236 69013 78607573 5809663 77232
56 2000 Asia 3488405040 256892044 148450 697689629 870077984 381710232 97027500 84816 19356059 2148598 4231099 77705808 584748329 549045116
57 2000 Europe 745596883 571107445 2243767 47729841 764336 3099355 0 4782 396383 77628 15296 78139 113729094 129943
58 2000 Mideast 409782300 16678853 4956077 376076983 1141268 88823 0 445000 15420 142471 0 5898000 1775785 0
59 2000 West. Hem 823033224 709488193 5993536 4048465 1720060 3214777 161765 1468955 232021 628141 6959 4457945 76349251 13592264
60 2005 Africa 703623000 397001958 105776 213125720 2118924 182161 0 838 61177 1082939 73053 79035014 7178005 84834
61 2005 Asia 3666155352 275275093 127286 749421842 940599251 466101118 107029655 91049 20940691 2306979 4574392 79217233 524304023 555845044
62 2005 Europe 744761600 559337643 2123463 51230517 996551 3059535 0 5105 412726 61087 17648 186360 114977698 426992
63 2005 Mideast 445958853 18237497 5309425 408154695 1454979 105908 0 19500 17500 152950 0 7079400 2652435 0
64 2005 West. Hem 875196370 740879276 6604378 4521572 2191657 4668399 191600 1559581 437055 705878 79864 5830711 94709150 12979998
65 2010 Africa 799492401 460005841 106121 246404472 2347387 224181 0 951 74969 1183246 91857 77615288 8889456 97374
66 2010 Asia 3857553138 287921863 123356 804756836 1008830303 478920926 108029951 94666 22509620 2580737 4915980 81146609 541453380 578913544
67 2010 Europe 754067657 557677984 1378063 51222711 1125071 1556416 0 4404 490470 48120 20000 232716 130820732 548795
68 2010 Mideast 491293037 19813797 5604499 448620067 2284384 142503 0 0 19000 362367 0 8025046 3612800 0
69 2010 West. Hem 928209348 786493468 6811270 4478680 2755503 4402911 313241 1651017 682441 665592 87304 7244680 103547575 10970832

70 rows × 16 columns

複数の列を代入 (ver.2)

代入をしなくとも以下のように書ける

In [312]:
regionals= regional[['year','region','population','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']]
regionals
Out[312]:
year region population christianity_all judaism_all islam_all hinduism_all buddhism_all shinto_all zoroastrianism_all sikhism_all baha’i_all jainism_all animism_all noreligion_all syncretism_all
0 1945 Africa 29073000 14588060 80487 5051475 137290 53 0 0 1536 2021 0 9162018 7396 831
1 1945 Asia 663450000 9919091 30369 36260345 5230216 113681431 55228775 2710 12525 7243 0 22525760 30637661 423153390
2 1945 Europe 560750000 420908000 6068020 29353397 21691 725632 0 0 1748 6231 181 1294177 99829250 5896
3 1945 Mideast 65219000 4011695 623240 60095064 0 0 0 10000 0 0 0 0 561 0
4 1945 West. Hem 289375655 251923444 5207284 0 0 1830820 0 0 5000 0 0 228125 23011662 5500000
5 1950 Africa 33707000 16793713 97006 5508523 195524 194 0 0 1943 3004 0 11084152 19918 973
6 1950 Asia 1300208016 45163397 54754 189121761 301106975 158063522 65452839 114462 5910591 453734 1816754 76081638 69193934 425681485
7 1950 Europe 486520000 347718164 5336066 30109208 44995 759624 0 0 10022 8041 500 1238087 100773236 9763
8 1950 Mideast 77683000 5113854 1630211 69360805 0 0 0 5000 0 172960 0 0 0 0
9 1950 West. Hem 322455008 281690994 6580257 20770 2006 188562 0 0 10001 1000 0 450003 22938228 6249873
10 1955 Africa 34925000 18937318 117741 6002686 278538 707 0 0 2457 7593 0 9419390 53634 1139
11 1955 Asia 1436233000 58967413 81070 210722747 328331380 177963621 68145114 126582 6342714 738141 1619287 82851650 161895190 378770746
12 1955 Europe 603716000 441172436 5178671 33390170 93684 806776 0 0 57446 15068 1375 1189903 118537427 26391
13 1955 Mideast 102730000 5654101 1966399 93953674 0 0 0 14180 0 0 0 0 270 5588
14 1955 West. Hem 358220000 311270834 5642323 2730 1003 613095 0 0 5000 500 0 250001 23641928 6898286
15 1960 Africa 148806000 61557803 138994 42908236 363925 3416 0 0 2971 157462 0 42355767 265053 4646
16 1960 Asia 1594029976 74184616 80005 240171009 360471285 196663980 71357167 170443 7980296 899468 2029510 89171314 278617080 317448262
17 1960 Europe 639466000 458326158 5068023 35477503 142373 853421 0 0 104871 21419 2250 1141720 133709658 37975
18 1960 Mideast 128887000 5473940 2135285 116514804 0 0 0 0 0 200000 0 2800000 277 0
19 1960 West. Hem 409598148 367425078 6306549 51536 191584 2918342 0 0 0 0 0 300000 22037603 7525200
20 1965 Africa 219965000 98101226 147929 56667388 548874 4572 0 324 25853 557883 28913 61942649 354423 14203
21 1965 Asia 1772609960 85484649 79304 275213701 396909711 209671102 74982591 138682 8717537 1046723 2309710 94583167 305127190 350788060
22 1965 Europe 676315000 476176756 4983768 36814738 191110 900068 0 0 152295 28308 3125 1093535 147965351 49559
23 1965 Mideast 159755000 6054509 2625113 145848262 0 0 0 9938 0 17627 0 2995006 47680 0
24 1965 West. Hem 450956507 408896646 6417565 89968 213487 2017642 0 0 0 8350 0 279349 20603206 7993000
25 1970 Africa 255537000 122086968 151537 66818285 991566 11299 0 472 26094 701507 32861 63335604 446303 17679
26 1970 Asia 2013375984 102736795 78269 318451549 448086953 226489880 79155350 106789 10441204 1177687 2590921 98686228 398889032 370782297
27 1970 Europe 703129248 488279742 4883835 38264883 242896 955963 0 410 199719 49039 4000 1047415 162011668 62146
28 1970 Mideast 184476000 8264204 2584234 168490055 7470 0 0 0 0 96033 0 3326100 153410 0
29 1970 West. Hem 498934000 455237967 7135534 317516 495604 1345492 1000 0 19615 270712 980 613877 27337768 8294607
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
40 1985 Africa 432444000 228658879 164828 125892684 1463736 72574 0 607 37537 1074228 49895 69685451 2149016 43652
41 1985 Asia 2525823952 175024514 100490 313273334 598009426 334462502 92520741 262761 14651868 1978767 3508357 90948268 542261654 425483823
42 1985 Europe 769476405 496457481 4364409 42150125 474973 1086688 0 523 217500 72559 9648 713756 210577941 89957
43 1985 Mideast 285529000 11187498 3630574 262830380 82000 35000 0 0 15000 7950 0 4265733 22000 9000
44 1985 West. Hem 655792000 595590679 8522694 2982068 1592400 2013925 0 0 0 46920 0 453731 33185698 10002600
45 1990 Africa 483823000 265493449 142152 135413988 1762136 100263 0 720 44358 1150689 57010 73843670 2896489 57936
46 1990 Asia 2937844992 222571100 104493 508795898 656018252 371399010 94546096 314540 18621706 2301416 3809813 103439157 561364124 459167251
47 1990 Europe 845942719 547627544 4094416 43630843 545390 1260132 0 610 228000 100313 11531 970327 236076477 243791
48 1990 Mideast 337954000 16072151 3746388 308955332 318199 114686 0 500030 48899 224304 0 3276509 1641499 28966
49 1990 West. Hem 707106969 643316975 6782098 2884257 1205851 2373664 61724 62501 258517 1288261 6410 652668 36292691 9701954
50 1995 Africa 565658000 314790124 121360 163595753 1317227 66300 0 782 40993 1246159 61627 74918182 5092209 48635
51 1995 Asia 3228425512 259779112 195111 606168389 717365785 408209553 96076062 247242 18492938 2435313 4014448 112240465 574222830 492135244
52 1995 Europe 745952000 512007252 2565349 41542293 699215 1497063 0 731 294718 129783 13413 1232015 176181859 302461
53 1995 Mideast 374116000 17023562 4638374 340695671 4791 0 0 472500 1166 278675 0 3534249 323129 0
54 1995 West. Hem 754990021 681814919 6552112 2988500 1481887 2182414 60945 765727 245269 757649 6684 981414 46460699 10533280
55 2000 Africa 618965000 336756649 104482 188503322 1902086 142869 0 845 53080 1083236 69013 78607573 5809663 77232
56 2000 Asia 3488405040 256892044 148450 697689629 870077984 381710232 97027500 84816 19356059 2148598 4231099 77705808 584748329 549045116
57 2000 Europe 745596883 571107445 2243767 47729841 764336 3099355 0 4782 396383 77628 15296 78139 113729094 129943
58 2000 Mideast 409782300 16678853 4956077 376076983 1141268 88823 0 445000 15420 142471 0 5898000 1775785 0
59 2000 West. Hem 823033224 709488193 5993536 4048465 1720060 3214777 161765 1468955 232021 628141 6959 4457945 76349251 13592264
60 2005 Africa 703623000 397001958 105776 213125720 2118924 182161 0 838 61177 1082939 73053 79035014 7178005 84834
61 2005 Asia 3666155352 275275093 127286 749421842 940599251 466101118 107029655 91049 20940691 2306979 4574392 79217233 524304023 555845044
62 2005 Europe 744761600 559337643 2123463 51230517 996551 3059535 0 5105 412726 61087 17648 186360 114977698 426992
63 2005 Mideast 445958853 18237497 5309425 408154695 1454979 105908 0 19500 17500 152950 0 7079400 2652435 0
64 2005 West. Hem 875196370 740879276 6604378 4521572 2191657 4668399 191600 1559581 437055 705878 79864 5830711 94709150 12979998
65 2010 Africa 799492401 460005841 106121 246404472 2347387 224181 0 951 74969 1183246 91857 77615288 8889456 97374
66 2010 Asia 3857553138 287921863 123356 804756836 1008830303 478920926 108029951 94666 22509620 2580737 4915980 81146609 541453380 578913544
67 2010 Europe 754067657 557677984 1378063 51222711 1125071 1556416 0 4404 490470 48120 20000 232716 130820732 548795
68 2010 Mideast 491293037 19813797 5604499 448620067 2284384 142503 0 0 19000 362367 0 8025046 3612800 0
69 2010 West. Hem 928209348 786493468 6811270 4478680 2755503 4402911 313241 1651017 682441 665592 87304 7244680 103547575 10970832

70 rows × 16 columns

年代でグループにし、値をまとめる

In [319]:
regional= pd.read_csv('csv/regional.csv')
regionals= regional[['year','population','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year= regionals.groupby(['year']).sum()
regionals_by_year
Out[319]:
population christianity_all judaism_all islam_all hinduism_all buddhism_all shinto_all zoroastrianism_all sikhism_all baha’i_all jainism_all animism_all noreligion_all syncretism_all
year
1945 1607867655 701350290 12009400 130760281 5389197 116237936 55228775 12710 20809 15495 181 33210080 153486530 428660117
1950 2220573024 696480122 13698294 294121067 301349500 159011902 65452839 119462 5932557 638739 1817254 88853880 192925316 431942094
1955 2535824000 836002102 12986204 344072007 328704605 179384199 68145114 140762 6407617 761302 1620662 93710944 304128449 385702150
1960 2920787124 966967595 13728856 435123088 361169167 200439159 71357167 170443 8088138 1278349 2031760 135768801 434629671 325016083
1965 3279601467 1074713786 14253679 514634057 397863182 212593384 74982591 148944 8895685 1658891 2341748 160893706 474097850 358844822
1970 3655452232 1176605676 14833409 592342288 449824489 228802634 79156350 107671 10686632 2294978 2628762 167009224 588838181 379156729
1975 4022668800 1300116609 15914548 663674348 488621807 260324284 85416548 179084 12477870 2607053 2942380 168615279 690431832 372344153
1980 4265381362 1392078609 16606995 647139477 537594394 298402116 89429228 192461 14276856 3205049 3258083 165629178 737801266 398417206
1985 4669065357 1506919051 16782995 747128591 601622535 337670689 92520741 263891 14921905 3180424 3567900 166066939 788196309 435629032
1990 5312671680 1695081219 14869547 999680318 659849828 375247755 94607820 878401 19201480 5064983 3884764 182182331 838271280 469199898
1995 5669141533 1785414969 14072306 1154990606 720868905 411955330 96137007 1486982 19075084 4847579 4096172 192906325 802280726 503019620
2000 6085782447 1890923184 13446312 1314048240 875605734 388256056 97189265 2004398 20052963 4080074 4322367 166747465 782412122 562844555
2005 6435695175 1990731467 14270328 1426454346 947361362 474117121 107221255 1676073 21869149 4309833 4744957 171348718 743821311 569336868
2010 6830615581 2111912953 14023309 1555482766 1017342648 485246937 108343192 1751038 23776500 4840062 5115141 174264339 788323943 590530545

特定の列を総人口で割る

人口で割ってから比率を出すことで人口増加の影響が及ばなくする

In [248]:
regionals = regional['christianity_all'] / regional['population']
regionals
Out[248]:
0     0.501773
1     0.014951
2     0.750616
3     0.061511
4     0.870576
5     0.498226
6     0.034736
7     0.714705
8     0.065830
9     0.873582
10    0.542228
11    0.041057
12    0.730762
13    0.055038
14    0.868938
15    0.413678
16    0.046539
17    0.716733
18    0.042471
19    0.897038
20    0.445986
21    0.048225
22    0.704075
23    0.037899
24    0.906732
25    0.477766
26    0.051027
27    0.694438
28    0.044798
29    0.912421
        ...   
40    0.528760
41    0.069294
42    0.645189
43    0.039182
44    0.908201
45    0.548741
46    0.075760
47    0.647358
48    0.047557
49    0.909787
50    0.556503
51    0.080466
52    0.686381
53    0.045503
54    0.903078
55    0.544064
56    0.073642
57    0.765973
58    0.040702
59    0.862041
60    0.564225
61    0.075085
62    0.751029
63    0.040895
64    0.846529
65    0.575372
66    0.074638
67    0.739560
68    0.040330
69    0.847323
Length: 70, dtype: float64

全ての列を総人口で割る

数値が入っていないとき、lambdaを使う。通常は以下のようにfooを代入し書くことができる。

def foo(row):

return row / row['population'] * 100

df.apply(foo * 100 , axis=1)

In [327]:
regional= pd.read_csv('csv/regional.csv')
regionals= regional[['year','population','christianity_all','judaism_all','islam_all','hinduism_all','buddhism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year= regionals.groupby(['year']).sum()
df = regionals_by_year

df.apply(lambda row: row / row['population'] * 100 , axis=1)
Out[327]:
population christianity_all judaism_all islam_all hinduism_all buddhism_all shinto_all zoroastrianism_all sikhism_all baha’i_all jainism_all animism_all noreligion_all syncretism_all
year
1945 100.0 43.619902 0.746915 8.132528 0.335177 7.229322 3.434908 0.000790 0.001294 0.000964 0.000011 2.065473 9.545968 26.660162
1950 100.0 31.364883 0.616881 13.245278 13.570799 7.160850 2.947565 0.005380 0.267163 0.028765 0.081837 4.001394 8.688087 19.451830
1955 100.0 32.967671 0.512110 13.568450 12.962438 7.074000 2.687297 0.005551 0.252684 0.030022 0.063911 3.695483 11.993279 15.210131
1960 100.0 33.106404 0.470040 14.897460 12.365474 6.862505 2.443080 0.005836 0.276916 0.043767 0.069562 4.648363 14.880567 11.127688
1965 100.0 32.769646 0.434616 15.691969 12.131449 6.482293 2.286332 0.004542 0.271243 0.050582 0.071403 4.905892 14.455959 10.941720
1970 100.0 32.187691 0.405789 16.204350 12.305577 6.259216 2.165432 0.002945 0.292348 0.062782 0.071913 4.568771 16.108491 10.372362
1975 100.0 32.319753 0.395622 16.498359 12.146707 6.471432 2.123380 0.004452 0.310189 0.064809 0.073145 4.191627 17.163527 9.256147
1980 100.0 32.636674 0.389344 15.171902 12.603665 6.995907 2.096629 0.004512 0.334715 0.075141 0.076384 3.883104 17.297428 9.340717
1985 100.0 32.274533 0.359451 16.001673 12.885288 7.232083 1.981569 0.005652 0.319591 0.068117 0.076416 3.556749 16.881244 9.330112
1990 100.0 31.906380 0.279888 18.816904 12.420301 7.063259 1.780796 0.016534 0.361428 0.095338 0.073123 3.429204 15.778714 8.831713
1995 100.0 31.493568 0.248226 20.373289 12.715663 7.266626 1.695795 0.026229 0.336472 0.085508 0.072254 3.402743 14.151715 8.872942
2000 100.0 31.071160 0.220946 21.592100 14.387727 6.379723 1.596989 0.032936 0.329505 0.067043 0.071024 2.739951 12.856393 9.248516
2005 100.0 30.932656 0.221737 22.164728 14.720420 7.366992 1.666040 0.026043 0.339810 0.066968 0.073729 2.662474 11.557746 8.846548
2010 100.0 30.918340 0.205301 22.772219 14.893865 7.104000 1.586141 0.025635 0.348087 0.070858 0.074886 2.551225 11.541038 8.645349

宗教別の年代増加

In [323]:
plt.figure(figsize=(13, 8))
sns.heatmap(regionals_by_year, cmap='Purples')
Out[323]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa56fb3f1d0>

人口は増えているが、宗教人口はそれほどの増加がない。キリスト教、イスラム教、ヒンデュー教、無宗教人口が徐々に増加していることがわかる

各種機能をインストール

In [160]:
%matplotlib inline
import pandas as pd
import numpy as np
import seaborn as sns
from pandas import Series, DataFrame
from matplotlib import pyplot as plt

csvファイルの読み込み

In [246]:
regional = pd.read_csv('csv/regional.csv')

宗教別の年代増加

In [247]:
regionals = regional[['year','population','christianity_all','islam_all','judaism_all','hinduism_all','buddhism_all','shinto_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year = regionals.groupby(['year']).sum()
df = regionals_by_year

df_aspect = df.apply(lambda row: row / row['population'] * 100 , axis =1)
df_result = df_aspect.drop('population', axis =1)
In [248]:
plt.figure(figsize=(16,8))
sns.heatmap(df_result.T, square=True,  cmap='Purples', annot=True, fmt="1.0f")
Out[248]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f4877728390>

宗教別の年代増加 (7代宗教とその他宗教別)

In [249]:
regionals = regional[['year','population','christianity_all','islam_all','hinduism_all','buddhism_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year = regionals.groupby(['year']).sum()
df = regionals_by_year

df_aspect = df.apply(lambda row: row / row['population'] * 100 , axis =1)
df_result = df_aspect.drop('population', axis =1)

plt.figure(figsize=(13,6))
sns.heatmap(df_result.T, square=True,  cmap='Purples', annot=True, fmt="1.0f")

regionals = regional[['year','population','judaism_all','shinto_all','zoroastrianism_all','sikhism_all','baha’i_all','jainism_all']]
regionals_by_year = regionals.groupby(['year']).sum()
df = regionals_by_year

df_aspect = df.apply(lambda row: row / row['population'] * 100 , axis =1)
df_result = df_aspect.drop('population', axis =1)

plt.figure(figsize=(13,5))
sns.heatmap(df_result.T, square=True,  cmap='Purples', annot=True, fmt="1.0f")
Out[249]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f48773b9978>

宗教別の年代増加

年代でグループ化し、'.T'でxy 軸の反転をする。

In [251]:
regional = pd.read_csv('csv/regional.csv')
regionals = regional[['year','christianity_all','islam_all','judaism_all','hinduism_all','buddhism_all','shinto_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year = regionals.groupby(['year']).sum()
regionals_by_year.T
Out[251]:
year 1945 1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010
christianity_all 701350290 696480122 836002102 966967595 1074713786 1176605676 1300116609 1392078609 1506919051 1695081219 1785414969 1890923184 1990731467 2111912953
islam_all 130760281 294121067 344072007 435123088 514634057 592342288 663674348 647139477 747128591 999680318 1154990606 1314048240 1426454346 1555482766
judaism_all 12009400 13698294 12986204 13728856 14253679 14833409 15914548 16606995 16782995 14869547 14072306 13446312 14270328 14023309
hinduism_all 5389197 301349500 328704605 361169167 397863182 449824489 488621807 537594394 601622535 659849828 720868905 875605734 947361362 1017342648
buddhism_all 116237936 159011902 179384199 200439159 212593384 228802634 260324284 298402116 337670689 375247755 411955330 388256056 474117121 485246937
shinto_all 55228775 65452839 68145114 71357167 74982591 79156350 85416548 89429228 92520741 94607820 96137007 97189265 107221255 108343192
animism_all 33210080 88853880 93710944 135768801 160893706 167009224 168615279 165629178 166066939 182182331 192906325 166747465 171348718 174264339
noreligion_all 153486530 192925316 304128449 434629671 474097850 588838181 690431832 737801266 788196309 838271280 802280726 782412122 743821311 788323943
syncretism_all 428660117 431942094 385702150 325016083 358844822 379156729 372344153 398417206 435629032 469199898 503019620 562844555 569336868 590530545

1945年の行の値で他の年代を割る

In [252]:
regional = pd.read_csv('csv/regional.csv')
regionals = regional[['year','christianity_all','islam_all','judaism_all','hinduism_all','buddhism_all','shinto_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year = regionals.groupby(['year']).sum()
df = regionals_by_year.T
df= df.apply(lambda row: row / row[1945]  , axis=1)
df
Out[252]:
year 1945 1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010
christianity_all 1.0 0.993056 1.191989 1.378723 1.532350 1.677629 1.853734 1.984855 2.148597 2.416882 2.545682 2.696118 2.838427 3.011210
islam_all 1.0 2.249315 2.631319 3.327640 3.935706 4.529986 5.075504 4.949052 5.713727 7.645137 8.832886 10.049292 10.908927 11.895682
judaism_all 1.0 1.140631 1.081337 1.143176 1.186877 1.235150 1.325174 1.382833 1.397488 1.238159 1.171774 1.119649 1.188263 1.167694
hinduism_all 1.0 55.917329 60.993244 67.017251 73.826060 83.467813 90.666904 99.754081 111.634912 122.439359 133.761840 162.474249 175.788965 188.774440
buddhism_all 1.0 1.367986 1.543250 1.724387 1.828950 1.968399 2.239581 2.567166 2.904996 3.228273 3.544070 3.340184 4.078850 4.174600
shinto_all 1.0 1.185122 1.233870 1.292029 1.357673 1.433245 1.546595 1.619251 1.675227 1.713017 1.740705 1.759758 1.941402 1.961716
animism_all 1.0 2.675509 2.821762 4.088180 4.844725 5.028871 5.077232 4.987316 5.000498 5.485754 5.808668 5.020990 5.159539 5.247333
noreligion_all 1.0 1.256953 1.981467 2.831712 3.088856 3.836416 4.498322 4.806945 5.135280 5.461530 5.227043 5.097595 4.846167 5.136112
syncretism_all 1.0 1.007656 0.899785 0.758214 0.837131 0.884516 0.868623 0.929448 1.016257 1.094573 1.173470 1.313032 1.328178 1.377620

計算があっているかを確認確認する

In [226]:
q = 6964802102 / 701350290
print(q)
9.930561377539318

1945年を基準にした各宗教の成長率 ヒートマップ

In [253]:
regional = pd.read_csv('csv/regional.csv')
regionals = regional[['year','christianity_all','islam_all','judaism_all','hinduism_all','buddhism_all','shinto_all','animism_all','noreligion_all','syncretism_all']]
regionals_by_year = regionals.groupby(['year']).sum()
df = regionals_by_year.T
df=df.apply(lambda row: row / row[1945]  , axis=1)
plt.figure(figsize=(16,8))
sns.heatmap(df, square=True,  cmap='Purples', annot=True, fmt="1.0f")
Out[253]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f48774f44e0>

年代別エリア宗教人口(キリスト教、イスラム教、ユダヤ教)

In [189]:
regional = pd.read_csv('csv/regional.csv')

fig, axes = plt.subplots(nrows=1, ncols=3)
colormap = plt.cm.Set2

christianity_year = regional.groupby(['year','region']).christianity_all.sum()
christianity_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False,ax= axes[0],figsize=(18,8) , legend=False)
axes[0].set_title('Christianity', y=1.08,size=12)

islam_year = regional.groupby(['year','region']).islam_all.sum()
islam_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, ax= axes[1], legend= False)
axes[1].set_title('Islam', y=1.08,size=12)

judaism_year = regional.groupby(['year','region']).judaism_all.sum()
judaism_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, ax= axes[2], legend= False)
axes[2].legend(bbox_to_anchor=(-1.4, -0.2, 2.4, 0.1), loc=10,prop={'size':12},
           ncol=5, mode="expand", borderaxespad=0.)
axes[2].set_title('Judaism', y=1.08,size=12)

plt.tight_layout()
plt.show()

年代別エリア宗教人口(ヒンデュー教、仏教、神道)

In [190]:
fig, axes = plt.subplots(nrows=1, ncols=3)
colormap = plt.cm.Set2

christianity_year = regional.groupby(['year','region']).hinduism_all.sum()
christianity_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False,ax= axes[0],figsize=(18,8) , legend=False)
axes[0].set_title('Hinduism', y=1.08,size=12)

islam_year = regional.groupby(['year','region']).buddhism_all.sum()
islam_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, ax= axes[1], legend= False)
axes[1].set_title('Buddhism', y=1.08,size=12)

judaism_year = regional.groupby(['year','region']).shinto_all.sum()
judaism_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, ax= axes[2], legend= False)
axes[2].legend(bbox_to_anchor=(-1.4, -0.2, 2.4, 0.1), loc=10,prop={'size':12},
           ncol=5, mode="expand", borderaxespad=0.)
axes[2].set_title('Shinto', y=1.08,size=12)

plt.tight_layout()
plt.show()

年代別エリア宗教人口(精霊信仰、無宗教、重層信仰)

In [191]:
fig, axes = plt.subplots(nrows=1, ncols=3)
colormap = plt.cm.Set2

christianity_year = regional.groupby(['year','region']).animism_all.sum()
christianity_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False,ax= axes[0],figsize=(18,8) , legend=False)
axes[0].set_title('Animism', y=1.08,size=12)

islam_year = regional.groupby(['year','region']).noreligion_all.sum()
islam_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, ax= axes[1], legend= False)
axes[1].set_title('No religion', y=1.08,size=12)

judaism_year = regional.groupby(['year','region']).syncretism_all.sum()
judaism_year.unstack().plot(kind='bar',stacked=True,  colormap= colormap, grid=False, ax= axes[2])
axes[2].legend(bbox_to_anchor=(-1.4, -0.2, 2.4, 0.1), loc=10,prop={'size':12},
           ncol=5, mode="expand", borderaxespad=0.)
axes[2].set_title('Syncretism', y=1.08,size=12)

plt.tight_layout()
plt.show()

参考資料:

Global Religion 1945-2010: Plotly & Pandas visuals: https://www.kaggle.com/arthurtok/global-religion-1945-2010-plotly-pandas-visuals

pandas.DataFrame の列の抽出(射影)および行の抽出(選択)方法まとめ: https://akiyoko.hatenablog.jp/entry/2017/04/03/081630

seaborn.heatmap: https://seaborn.pydata.org/generated/seaborn.heatmap.html

pandas の loc、iloc、ix の違い – python: http://ailaby.com/lox_iloc_ix/

Seaborn でヒートマップを作成する: https://pythondatascience.plavox.info/seaborn/heatmap

グラフ作成のためのチートシートとPythonによる各種グラフの実装: https://qiita.com/4m1t0/items/76b0033edb545a78cef5

Dbpedia: https://wiki.dbpedia.org/

Ontology: http://mappings.dbpedia.org/server/ontology/classes/

SPARQL Endpoint interface to Python: https://rdflib.github.io/sparqlwrapper/

フェルミ推定(Fermi estimate)とは: 実際に調査するのが難しいようなとらえどころのない量を、いくつかの手掛かりを元に論理的に推論し、短時間で概算すること