Skip to content

Instantly share code, notes, and snippets.

@cavedave
Last active June 7, 2018 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cavedave/cc2bc82b47a2cdc14b8afb6e27fa9e1f to your computer and use it in GitHub Desktop.
Save cavedave/cc2bc82b47a2cdc14b8afb6e27fa9e1f to your computer and use it in GitHub Desktop.
Graph of countries watt usage versus birth rate
Country KWH PPPY Average Power Per Capita Birthrate
Afghanistan 141 16 45.1
Albania 2564 292 11.5
Algeria 1216 138 24.8
American Samoa 1845 210 23.5
Andorra 6565 749 10.2
Angola 401 45 40.9
Antigua and Barbuda 3205 365 13.8
Argentina 2643 301 18.7
Armenia 1671 190 13.3
Aruba 7039 803 10.6
Australia 9742 1112 13.3
Austria 8006 913 9.3
Azerbaijan 2025 231 19.4
Bahamas 4888 558 13.8
Bahrain 18130 2069 15
Bangladesh 351 40 19.2
Barbados 3087 352 12.2
Belarus 3448 393 11.5
Belgium 7099 810 11.9
Belize 1130 129 22.1
Benin 93 10 37.3
Bermuda 8506 971 11.9
Bhutan 2779 317 20.7
Bolivia 683 78 26
Bosnia and Herzegovina 2848 325 8.3
Botswana 1674 191 24.8
Brazil 2516 287 12.69
British Virgin Islands 2921 333 10.1
Brunei 8625 984 15.5
Bulgaria 4338 495 9.6
Burkina Faso 61 7 45
Burundi 36 4 33.3
Cabo Verde 542 61 21
Cambodia 256 29 25.4
Cameroon 250 28 34.2
Canada 14930 1704 11.2
Cayman Islands 10477 1196 14.5
Central African Republic 36 4 33.2
Chad 16 1 43.2
Chile 3739 426 14.5
China 4475 510 11.9
Colombia 1270 145 18.9
Comoros 51 5 29.4
Congo Democratic Republic of the 114 13 31.9
Congo Republic of the 185 21 42.5
Cook Islands 3308 377 16.8
Costa Rica 1888 215 15.9
Ivory Coast 244 27 32.8
Croatia 3933 449 9.4
Cuba 1400 68 11.8
Curacao 6495 741 13.6
Cyprus 3234 369 11.3
Czech Republic 5636 643 10.4
Denmark 5720 653 10.6
Djibouti 472 53 26.5
Dominica 1223 139 12.8
Dominican Republic 1427 162 21.1
Ecuador 1305 149 15.1
Egypt 1510 172 30.4
El Salvador 925 105 20
Equatorial Guinea 120 13 37.4
Eritrea 51 5 33.6
Estonia 6515 743 11
Ethiopia 65 7 35.7
Falkland Islands 4759 543 9
Faroe Islands 5945 678 11.9
Fiji 874 99 21.4
Finland 14732 1681 11.1
France 6448 736 12.6
French Polynesia 2453 280 17
Gabon 1207 137 27
Gambia 149 17 34.6
Georgia 1988 227 12.9
Germany 6602 753 8.1
Ghana 341 39 30.8
Gibraltar 6819 778 14.9
Greece 4919 561 9.2
Greenland 5196 593 14.5
Grenada 1798 205 16.5
Guam 9217 1052 20.6
Guatemala 586 66 30.5
Guinea 74 8 37.3
Guinea-Bissau 17 2 39.4
Guyana 1087 124 16.6
Haiti 38 4 26
Honduras 595 68 27.3
Hong Kong 5859 668 13.5
Hungary 2182 249 8.8
Iceland 50613 5777 14.1
India 1122 128 21.8
Indonesia 754 86 18.1
Iran 2632 300 18.2
Iraq 1101 125 31
Ireland 5047 576 16.3
Israel 7319 835 21.4
Italy 4692 535 9.1
Jamaica 942 107 15.2
Japan 7371 841 8.3
Jersey 6425 733 11.3
Jordan 1954 223 28.9
Kazakhstan 4956 565 22.5
Kenya 162 18 36.1
Kiribati 260 29 27.8
Korea North 1347 153 14.4
Korea South 9720 1109 9.4
Kosovo 1533 175 19.1
Kuwait 19062 2176 16
Kyrgyzstan 1920 219 27.1
Laos 555 63 28
Latvia 3459 394 9.1
Lebanon 2565 292 24.3
Lesotho 409 46 30.4
Liberia 69 7 36.1
Libya 1421 162 21.5
Liechtenstein 35848 4092 10.9
Lithuania 3468 395 11.3
Luxembourg 10647 1215 10.9
Macau 7532 859 10.6
Macedonia 3314 378 11.1
Madagascar 53 6 33.5
Malawi 102 11 44.6
Malaysia 4232 483 17.5
Maldives 763 87 22.4
Mali 80 9 45.4
Malta 4817 549 10.2
Marshall Islands 8177 933 31.1
Mauritania 217 24 33.2
Mauritius 1928 220 11.4
Mexico 1932 220 17.5
Micronesia Federated States of 1705 194 23.5
Moldova 1226 139 11
Mongolia 1847 210 25.1
Montenegro 4343 495 11.6
Montserrat 4061 463 9.3
Morocco 861 98 18.8
Mozambique 462 52 41.4
Myanmar 193 22 19.3
Namibia 1518 173 26
Nauru 2424 276 29.7
Nepal 134 15 24.3
Netherlands 6346 724 10.8
New Caledonia 7263 829 16.7
New Zealand 8939 1020 14.3
Nicaragua 739 84 23.2
Niger 64 7 46
Nigeria 128 14 36.9
Niue 3126 356 14.8
Northern Mariana Islands 4190 478 20.7
Norway 24006 2740 12.2
Oman 7450 850 31
Pakistan 405 46 27.5
West Bank 1927 220 32.8
Panama 2105 240 19.7
Papua New Guinea 441 50 30.9
Paraguay 1413 161 22.9
Peru 1268 144 19.9
Philippines 885 101 25.3
Poland 3686 420 10.2
Portugal 4245 484 9.2
Puerto Rico 5310 606 11.4
Qatar 15055 1718 11.9
Romania 2222 253 9.2
Russia 7481 854 12.6
Rwanda 38 4 42.1
Saint Helena Ascension and Tristan da Cunha 1193 136 8.5
Saint Kitts and Nevis 3821 436 12.5
Saint Lucia 1824 208 12.8
Saint Pierre and Miquelon 7479 852 8.3
Saint Vincent and the Grenadines 977 111 16.8
Samoa 502 57 24.8
Sao Tome and Principe 329 37 29.4
Saudi Arabia 9658 1102 22.9
Senegal 209 23 36.7
Serbia 3766 430 9
Seychelles 3219 367 18.6
Sierra Leone 33 3 38.4
Singapore 8160 931 9.5
Slovakia 5207 594 11.3
Slovenia 6572 750 10.7
Solomon Islands 124 14 34.3
Somalia 27 3 42.3
South Africa 3904 445 21
South Sudan 55 6 36.8
Spain 4818 550 10.2
Sri Lanka 494 56 17.4
Sudan 269 30 32.6
Suriname 3243 370 18.7
Swaziland 1033 117 31.1
Sweden 12853 1467 11.8
Switzerland 7091 809 10.2
Syria 989 112 27.6
Taiwan 10632 1213 8.5
Tajikistan 1440 164 28.7
Tanzania 95 10 39.8
Thailand 2404 274 12.4
Timor-Leste 99 11 39.2
Togo 141 16 30.9
Tonga 436 49 26.5
Trinidad and Tobago 7456 851 15.2
Tunisia 1341 153 18.6
Turkey 2578 294 16.7
Turkmenistan 2456 280 21.7
Turks and Caicos Islands 3888 443 14.8
U.S. Virgin Islands 5828 665 11.1
Uganda 70 8 44.1
Ukraine 3234 369 11
United Arab Emirates 16195 1848 9.6
United Kingdom 4795 547 12.9
United States 12071 1377 12.7
Uruguay 2984 340 14.1
Uzbekistan 1628 185 21.5
Vanuatu 201 22 31.1
Venezuela 2523 288 20.2
Vietnam 1312 149 16.6
Western Sahara 142 16 21.9
Yemen 189 21 35.9
Zambia 709 80 43.6
Zimbabwe 549 62 29.2
import numpy as np
import matplotlib.pyplot as plt
# Plot
plt.scatter(df['Birthrate'],df['Average Power Per Capita'] , alpha=0.5, marker='o')
plt.title('More Watts Less Children?')
plt.xlabel('Birthrate')
plt.ylabel('Watts')
plt.text(14.7, 5700, "Iceland",size=8)
plt.text(11.7, 4000, "Liechtenstein",size=8)
plt.text(45, 135, "Niger",size=8)
plt.text(40, 5800, "Correlation .44",size=8)
plt.show()
np.corrcoef(df['Birthrate'], df['Average Power Per Capita'])
# Pandas for managing datasets
import pandas as pd
# Matplotlib for additional customization
from matplotlib import pyplot as plt
%matplotlib inline
# Seaborn for plotting and styling
import seaborn as sns
df = pd.read_csv('Birth2.csv', index_col=0, encoding='mac_roman')
#df.columns = ['Intent', 'Expected','Confidence']
df.head()
import numpy as np
import matplotlib.pyplot as plt
# Create data
N = 500
x = np.random.rand(N)
y = np.random.rand(N)
colors = (0,0,0)
area = np.pi*3
# Plot
#plt.scatter(df['Birthrate'],df['Average Power Per Capita'], s=area, c=colors, alpha=0.5,linestyle='none', marker='o')
plt.scatter(df['Log'] ,df['Birthrate'], alpha=0.5, marker='o')#'Average Power Per Capita'
plt.title('More Watts Less Children?')
plt.xlabel('Log Watts PP')
plt.ylabel('Birthrate')
#Iceland 50613 5777 14.1 4.70426208
plt.text(4.55,14.7, "Iceland",size=8)#, transform=plt.transData
#plt.text(11.7, 4000, "Liechtenstein",size=8)#Liechtenstein
#Oman 7450 850 31 3.872156273
plt.text(3.9, 32, "Oman",size=8)
#Niger 64 7 46 1.806179974
plt.text(1.85,46, "Niger",size=8)
plt.text(4.1, 45, "Correlation .82",size=8)
#Norway 24006 2740 12.2
#plt.text(12.3, 2740, "Norway",size=8)
#UUnited States 12071 1377 12.7 4.08174325
plt.text( 4, 12.7,"United States",size=8)
#United States 12071 1377 12.7
#plt.text(12.7, 1400, "United States",size=8)
#United Kingdom 4795 547 12.9
#United Kingdom 4795 547 12.9 3.680788612
plt.text( 3.68,12.9, "UK",size=8)
#Liechtenstein
#plt.annotate('local max', xy=(2, 1000), xytext=(3, 1500))
#,arrowprops=dict(facecolor='black', shrink=0.05),)
plt.show()
#np.corrcoef(df['Birthrate'], df['Average Power Per Capita'])
plt.savefig('watts_birth.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment