In [2]:
import pandas as pd
import glob
In [5]:
print(glob.glob('data/*.csv'))
['data/gapminder_gdp_americas.csv', 'data/gapminder_gdp_europe.csv', 'data/gapminder_all.csv', 'data/gapminder_gdp_oceania.csv', 'data/gapminder_gdp_africa.csv', 'data/gapminder_gdp_asia.csv']
In [16]:
data_americas = pd.read_csv('data/gapminder_gdp_americas.csv')
In [17]:
print(data_americas)
continent country gdpPercap_1952 gdpPercap_1957 \
0 Americas Argentina 5911.315053 6856.856212
1 Americas Bolivia 2677.326347 2127.686326
2 Americas Brazil 2108.944355 2487.365989
3 Americas Canada 11367.161120 12489.950060
4 Americas Chile 3939.978789 4315.622723
5 Americas Colombia 2144.115096 2323.805581
6 Americas Costa Rica 2627.009471 2990.010802
7 Americas Cuba 5586.538780 6092.174359
8 Americas Dominican Republic 1397.717137 1544.402995
9 Americas Ecuador 3522.110717 3780.546651
10 Americas El Salvador 3048.302900 3421.523218
11 Americas Guatemala 2428.237769 2617.155967
12 Americas Haiti 1840.366939 1726.887882
13 Americas Honduras 2194.926204 2220.487682
14 Americas Jamaica 2898.530881 4756.525781
15 Americas Mexico 3478.125529 4131.546641
16 Americas Nicaragua 3112.363948 3457.415947
17 Americas Panama 2480.380334 2961.800905
18 Americas Paraguay 1952.308701 2046.154706
19 Americas Peru 3758.523437 4245.256698
20 Americas Puerto Rico 3081.959785 3907.156189
21 Americas Trinidad and Tobago 3023.271928 4100.393400
22 Americas United States 13990.482080 14847.127120
23 Americas Uruguay 5716.766744 6150.772969
24 Americas Venezuela 7689.799761 9802.466526
gdpPercap_1962 gdpPercap_1967 gdpPercap_1972 gdpPercap_1977 \
0 7133.166023 8052.953021 9443.038526 10079.026740
1 2180.972546 2586.886053 2980.331339 3548.097832
2 3336.585802 3429.864357 4985.711467 6660.118654
3 13462.485550 16076.588030 18970.570860 22090.883060
4 4519.094331 5106.654313 5494.024437 4756.763836
5 2492.351109 2678.729839 3264.660041 3815.807870
6 3460.937025 4161.727834 5118.146939 5926.876967
7 5180.755910 5690.268015 5305.445256 6380.494966
8 1662.137359 1653.723003 2189.874499 2681.988900
9 4086.114078 4579.074215 5280.994710 6679.623260
10 3776.803627 4358.595393 4520.246008 5138.922374
11 2750.364446 3242.531147 4031.408271 4879.992748
12 1796.589032 1452.057666 1654.456946 1874.298931
13 2291.156835 2538.269358 2529.842345 3203.208066
14 5246.107524 6124.703451 7433.889293 6650.195573
15 4581.609385 5754.733883 6809.406690 7674.929108
16 3634.364406 4643.393534 4688.593267 5486.371089
17 3536.540301 4421.009084 5364.249663 5351.912144
18 2148.027146 2299.376311 2523.337977 3248.373311
19 4957.037982 5788.093330 5937.827283 6281.290855
20 5108.344630 6929.277714 9123.041742 9770.524921
21 4997.523971 5621.368472 6619.551419 7899.554209
22 16173.145860 19530.365570 21806.035940 24072.632130
23 5603.357717 5444.619620 5703.408898 6504.339663
24 8422.974165 9541.474188 10505.259660 13143.950950
gdpPercap_1982 gdpPercap_1987 gdpPercap_1992 gdpPercap_1997 \
0 8997.897412 9139.671389 9308.418710 10967.281950
1 3156.510452 2753.691490 2961.699694 3326.143191
2 7030.835878 7807.095818 6950.283021 7957.980824
3 22898.792140 26626.515030 26342.884260 28954.925890
4 5095.665738 5547.063754 7596.125964 10118.053180
5 4397.575659 4903.219100 5444.648617 6117.361746
6 5262.734751 5629.915318 6160.416317 6677.045314
7 7316.918107 7532.924763 5592.843963 5431.990415
8 2861.092386 2899.842175 3044.214214 3614.101285
9 7213.791267 6481.776993 7103.702595 7429.455877
10 4098.344175 4140.442097 4444.231700 5154.825496
11 4820.494790 4246.485974 4439.450840 4684.313807
12 2011.159549 1823.015995 1456.309517 1341.726931
13 3121.760794 3023.096699 3081.694603 3160.454906
14 6068.051350 6351.237495 7404.923685 7121.924704
15 9611.147541 8688.156003 9472.384295 9767.297530
16 3470.338156 2955.984375 2170.151724 2253.023004
17 7009.601598 7034.779161 6618.743050 7113.692252
18 4258.503604 3998.875695 4196.411078 4247.400261
19 6434.501797 6360.943444 4446.380924 5838.347657
20 10330.989150 12281.341910 14641.587110 16999.433300
21 9119.528607 7388.597823 7370.990932 8792.573126
22 25009.559140 29884.350410 32003.932240 35767.433030
23 6920.223051 7452.398969 8137.004775 9230.240708
24 11152.410110 9883.584648 10733.926310 10165.495180
gdpPercap_2002 gdpPercap_2007
0 8797.640716 12779.379640
1 3413.262690 3822.137084
2 8131.212843 9065.800825
3 33328.965070 36319.235010
4 10778.783850 13171.638850
5 5755.259962 7006.580419
6 7723.447195 9645.061420
7 6340.646683 8948.102923
8 4563.808154 6025.374752
9 5773.044512 6873.262326
10 5351.568666 5728.353514
11 4858.347495 5186.050003
12 1270.364932 1201.637154
13 3099.728660 3548.330846
14 6994.774861 7320.880262
15 10742.440530 11977.574960
16 2474.548819 2749.320965
17 7356.031934 9809.185636
18 3783.674243 4172.838464
19 5909.020073 7408.905561
20 18855.606180 19328.709010
21 11460.600230 18008.509240
22 39097.099550 42951.653090
23 7727.002004 10611.462990
24 8605.047831 11415.805690
In [19]:
data_europe = pd.read_csv('data/gapminder_gdp_europe.csv', index_col='country')
In [20]:
data_europe
Out[20]:
gdpPercap_1952
gdpPercap_1957
gdpPercap_1962
gdpPercap_1967
gdpPercap_1972
gdpPercap_1977
gdpPercap_1982
gdpPercap_1987
gdpPercap_1992
gdpPercap_1997
gdpPercap_2002
gdpPercap_2007
country
Albania
1601.056136
1942.284244
2312.888958
2760.196931
3313.422188
3533.003910
3630.880722
3738.932735
2497.437901
3193.054604
4604.211737
5937.029526
Austria
6137.076492
8842.598030
10750.721110
12834.602400
16661.625600
19749.422300
21597.083620
23687.826070
27042.018680
29095.920660
32417.607690
36126.492700
Belgium
8343.105127
9714.960623
10991.206760
13149.041190
16672.143560
19117.974480
20979.845890
22525.563080
25575.570690
27561.196630
30485.883750
33692.605080
Bosnia and Herzegovina
973.533195
1353.989176
1709.683679
2172.352423
2860.169750
3528.481305
4126.613157
4314.114757
2546.781445
4766.355904
6018.975239
7446.298803
Bulgaria
2444.286648
3008.670727
4254.337839
5577.002800
6597.494398
7612.240438
8224.191647
8239.854824
6302.623438
5970.388760
7696.777725
10680.792820
Croatia
3119.236520
4338.231617
5477.890018
6960.297861
9164.090127
11305.385170
13221.821840
13822.583940
8447.794873
9875.604515
11628.388950
14619.222720
Czech Republic
6876.140250
8256.343918
10136.867130
11399.444890
13108.453600
14800.160620
15377.228550
16310.443400
14297.021220
16048.514240
17596.210220
22833.308510
Denmark
9692.385245
11099.659350
13583.313510
15937.211230
18866.207210
20422.901500
21688.040480
25116.175810
26406.739850
29804.345670
32166.500060
35278.418740
Finland
6424.519071
7545.415386
9371.842561
10921.636260
14358.875900
15605.422830
18533.157610
21141.012230
20647.164990
23723.950200
28204.590570
33207.084400
France
7029.809327
8662.834898
10560.485530
12999.917660
16107.191710
18292.635140
20293.897460
22066.442140
24703.796150
25889.784870
28926.032340
30470.016700
Germany
7144.114393
10187.826650
12902.462910
14745.625610
18016.180270
20512.921230
22031.532740
24639.185660
26505.303170
27788.884160
30035.801980
32170.374420
Greece
3530.690067
4916.299889
6017.190733
8513.097016
12724.829570
14195.524280
15268.420890
16120.528390
17541.496340
18747.698140
22514.254800
27538.411880
Hungary
5263.673816
6040.180011
7550.359877
9326.644670
10168.656110
11674.837370
12545.990660
12986.479980
10535.628550
11712.776800
14843.935560
18008.944440
Iceland
7267.688428
9244.001412
10350.159060
13319.895680
15798.063620
19654.962470
23269.607500
26923.206280
25144.392010
28061.099660
31163.201960
36180.789190
Ireland
5210.280328
5599.077872
6631.597314
7655.568963
9530.772896
11150.981130
12618.321410
13872.866520
17558.815550
24521.947130
34077.049390
40675.996350
Italy
4931.404155
6248.656232
8243.582340
10022.401310
12269.273780
14255.984750
16537.483500
19207.234820
22013.644860
24675.024460
27968.098170
28569.719700
Montenegro
2647.585601
3682.259903
4649.593785
5907.850937
7778.414017
9595.929905
11222.587620
11732.510170
7003.339037
6465.613349
6557.194282
9253.896111
Netherlands
8941.571858
11276.193440
12790.849560
15363.251360
18794.745670
21209.059200
21399.460460
23651.323610
26790.949610
30246.130630
33724.757780
36797.933320
Norway
10095.421720
11653.973040
13450.401510
16361.876470
18965.055510
23311.349390
26298.635310
31540.974800
33965.661150
41283.164330
44683.975250
49357.190170
Poland
4029.329699
4734.253019
5338.752143
6557.152776
8006.506993
9508.141454
8451.531004
9082.351172
7738.881247
10159.583680
12002.239080
15389.924680
Portugal
3068.319867
3774.571743
4727.954889
6361.517993
9022.247417
10172.485720
11753.842910
13039.308760
16207.266630
17641.031560
19970.907870
20509.647770
Romania
3144.613186
3943.370225
4734.997586
6470.866545
8011.414402
9356.397240
9605.314053
9696.273295
6598.409903
7346.547557
7885.360081
10808.475610
Serbia
3581.459448
4981.090891
6289.629157
7991.707066
10522.067490
12980.669560
15181.092700
15870.878510
9325.068238
7914.320304
7236.075251
9786.534714
Slovak Republic
5074.659104
6093.262980
7481.107598
8412.902397
9674.167626
10922.664040
11348.545850
12037.267580
9498.467723
12126.230650
13638.778370
18678.314350
Slovenia
4215.041741
5862.276629
7402.303395
9405.489397
12383.486200
15277.030170
17866.721750
18678.534920
14214.716810
17161.107350
20660.019360
25768.257590
Spain
3834.034742
4564.802410
5693.843879
7993.512294
10638.751310
13236.921170
13926.169970
15764.983130
18603.064520
20445.298960
24835.471660
28821.063700
Sweden
8527.844662
9911.878226
12329.441920
15258.296970
17832.024640
18855.725210
20667.381250
23586.929270
23880.016830
25266.594990
29341.630930
33859.748350
Switzerland
14734.232750
17909.489730
20431.092700
22966.144320
27195.113040
26982.290520
28397.715120
30281.704590
31871.530300
32135.323010
34480.957710
37506.419070
Turkey
1969.100980
2218.754257
2322.869908
2826.356387
3450.696380
4269.122326
4241.356344
5089.043686
5678.348271
6601.429915
6508.085718
8458.276384
United Kingdom
9979.508487
11283.177950
12477.177070
14142.850890
15895.116410
17428.748460
18232.424520
21664.787670
22705.092540
26074.531360
29478.999190
33203.261280
In [22]:
data_europe.info()
<class 'pandas.core.frame.DataFrame'>
Index: 30 entries, Albania to United Kingdom
Data columns (total 12 columns):
gdpPercap_1952 30 non-null float64
gdpPercap_1957 30 non-null float64
gdpPercap_1962 30 non-null float64
gdpPercap_1967 30 non-null float64
gdpPercap_1972 30 non-null float64
gdpPercap_1977 30 non-null float64
gdpPercap_1982 30 non-null float64
gdpPercap_1987 30 non-null float64
gdpPercap_1992 30 non-null float64
gdpPercap_1997 30 non-null float64
gdpPercap_2002 30 non-null float64
gdpPercap_2007 30 non-null float64
dtypes: float64(12)
memory usage: 3.0+ KB
In [23]:
data_europe.columns
Out[23]:
Index(['gdpPercap_1952', 'gdpPercap_1957', 'gdpPercap_1962', 'gdpPercap_1967',
'gdpPercap_1972', 'gdpPercap_1977', 'gdpPercap_1982', 'gdpPercap_1987',
'gdpPercap_1992', 'gdpPercap_1997', 'gdpPercap_2002', 'gdpPercap_2007'],
dtype='object')
In [24]:
data_europe.T
Out[24]:
country
Albania
Austria
Belgium
Bosnia and Herzegovina
Bulgaria
Croatia
Czech Republic
Denmark
Finland
France
...
Portugal
Romania
Serbia
Slovak Republic
Slovenia
Spain
Sweden
Switzerland
Turkey
United Kingdom
gdpPercap_1952
1601.056136
6137.076492
8343.105127
973.533195
2444.286648
3119.236520
6876.140250
9692.385245
6424.519071
7029.809327
...
3068.319867
3144.613186
3581.459448
5074.659104
4215.041741
3834.034742
8527.844662
14734.23275
1969.100980
9979.508487
gdpPercap_1957
1942.284244
8842.598030
9714.960623
1353.989176
3008.670727
4338.231617
8256.343918
11099.659350
7545.415386
8662.834898
...
3774.571743
3943.370225
4981.090891
6093.262980
5862.276629
4564.802410
9911.878226
17909.48973
2218.754257
11283.177950
gdpPercap_1962
2312.888958
10750.721110
10991.206760
1709.683679
4254.337839
5477.890018
10136.867130
13583.313510
9371.842561
10560.485530
...
4727.954889
4734.997586
6289.629157
7481.107598
7402.303395
5693.843879
12329.441920
20431.09270
2322.869908
12477.177070
gdpPercap_1967
2760.196931
12834.602400
13149.041190
2172.352423
5577.002800
6960.297861
11399.444890
15937.211230
10921.636260
12999.917660
...
6361.517993
6470.866545
7991.707066
8412.902397
9405.489397
7993.512294
15258.296970
22966.14432
2826.356387
14142.850890
gdpPercap_1972
3313.422188
16661.625600
16672.143560
2860.169750
6597.494398
9164.090127
13108.453600
18866.207210
14358.875900
16107.191710
...
9022.247417
8011.414402
10522.067490
9674.167626
12383.486200
10638.751310
17832.024640
27195.11304
3450.696380
15895.116410
gdpPercap_1977
3533.003910
19749.422300
19117.974480
3528.481305
7612.240438
11305.385170
14800.160620
20422.901500
15605.422830
18292.635140
...
10172.485720
9356.397240
12980.669560
10922.664040
15277.030170
13236.921170
18855.725210
26982.29052
4269.122326
17428.748460
gdpPercap_1982
3630.880722
21597.083620
20979.845890
4126.613157
8224.191647
13221.821840
15377.228550
21688.040480
18533.157610
20293.897460
...
11753.842910
9605.314053
15181.092700
11348.545850
17866.721750
13926.169970
20667.381250
28397.71512
4241.356344
18232.424520
gdpPercap_1987
3738.932735
23687.826070
22525.563080
4314.114757
8239.854824
13822.583940
16310.443400
25116.175810
21141.012230
22066.442140
...
13039.308760
9696.273295
15870.878510
12037.267580
18678.534920
15764.983130
23586.929270
30281.70459
5089.043686
21664.787670
gdpPercap_1992
2497.437901
27042.018680
25575.570690
2546.781445
6302.623438
8447.794873
14297.021220
26406.739850
20647.164990
24703.796150
...
16207.266630
6598.409903
9325.068238
9498.467723
14214.716810
18603.064520
23880.016830
31871.53030
5678.348271
22705.092540
gdpPercap_1997
3193.054604
29095.920660
27561.196630
4766.355904
5970.388760
9875.604515
16048.514240
29804.345670
23723.950200
25889.784870
...
17641.031560
7346.547557
7914.320304
12126.230650
17161.107350
20445.298960
25266.594990
32135.32301
6601.429915
26074.531360
gdpPercap_2002
4604.211737
32417.607690
30485.883750
6018.975239
7696.777725
11628.388950
17596.210220
32166.500060
28204.590570
28926.032340
...
19970.907870
7885.360081
7236.075251
13638.778370
20660.019360
24835.471660
29341.630930
34480.95771
6508.085718
29478.999190
gdpPercap_2007
5937.029526
36126.492700
33692.605080
7446.298803
10680.792820
14619.222720
22833.308510
35278.418740
33207.084400
30470.016700
...
20509.647770
10808.475610
9786.534714
18678.314350
25768.257590
28821.063700
33859.748350
37506.41907
8458.276384
33203.261280
12 rows × 30 columns
In [25]:
data_europe
Out[25]:
gdpPercap_1952
gdpPercap_1957
gdpPercap_1962
gdpPercap_1967
gdpPercap_1972
gdpPercap_1977
gdpPercap_1982
gdpPercap_1987
gdpPercap_1992
gdpPercap_1997
gdpPercap_2002
gdpPercap_2007
country
Albania
1601.056136
1942.284244
2312.888958
2760.196931
3313.422188
3533.003910
3630.880722
3738.932735
2497.437901
3193.054604
4604.211737
5937.029526
Austria
6137.076492
8842.598030
10750.721110
12834.602400
16661.625600
19749.422300
21597.083620
23687.826070
27042.018680
29095.920660
32417.607690
36126.492700
Belgium
8343.105127
9714.960623
10991.206760
13149.041190
16672.143560
19117.974480
20979.845890
22525.563080
25575.570690
27561.196630
30485.883750
33692.605080
Bosnia and Herzegovina
973.533195
1353.989176
1709.683679
2172.352423
2860.169750
3528.481305
4126.613157
4314.114757
2546.781445
4766.355904
6018.975239
7446.298803
Bulgaria
2444.286648
3008.670727
4254.337839
5577.002800
6597.494398
7612.240438
8224.191647
8239.854824
6302.623438
5970.388760
7696.777725
10680.792820
Croatia
3119.236520
4338.231617
5477.890018
6960.297861
9164.090127
11305.385170
13221.821840
13822.583940
8447.794873
9875.604515
11628.388950
14619.222720
Czech Republic
6876.140250
8256.343918
10136.867130
11399.444890
13108.453600
14800.160620
15377.228550
16310.443400
14297.021220
16048.514240
17596.210220
22833.308510
Denmark
9692.385245
11099.659350
13583.313510
15937.211230
18866.207210
20422.901500
21688.040480
25116.175810
26406.739850
29804.345670
32166.500060
35278.418740
Finland
6424.519071
7545.415386
9371.842561
10921.636260
14358.875900
15605.422830
18533.157610
21141.012230
20647.164990
23723.950200
28204.590570
33207.084400
France
7029.809327
8662.834898
10560.485530
12999.917660
16107.191710
18292.635140
20293.897460
22066.442140
24703.796150
25889.784870
28926.032340
30470.016700
Germany
7144.114393
10187.826650
12902.462910
14745.625610
18016.180270
20512.921230
22031.532740
24639.185660
26505.303170
27788.884160
30035.801980
32170.374420
Greece
3530.690067
4916.299889
6017.190733
8513.097016
12724.829570
14195.524280
15268.420890
16120.528390
17541.496340
18747.698140
22514.254800
27538.411880
Hungary
5263.673816
6040.180011
7550.359877
9326.644670
10168.656110
11674.837370
12545.990660
12986.479980
10535.628550
11712.776800
14843.935560
18008.944440
Iceland
7267.688428
9244.001412
10350.159060
13319.895680
15798.063620
19654.962470
23269.607500
26923.206280
25144.392010
28061.099660
31163.201960
36180.789190
Ireland
5210.280328
5599.077872
6631.597314
7655.568963
9530.772896
11150.981130
12618.321410
13872.866520
17558.815550
24521.947130
34077.049390
40675.996350
Italy
4931.404155
6248.656232
8243.582340
10022.401310
12269.273780
14255.984750
16537.483500
19207.234820
22013.644860
24675.024460
27968.098170
28569.719700
Montenegro
2647.585601
3682.259903
4649.593785
5907.850937
7778.414017
9595.929905
11222.587620
11732.510170
7003.339037
6465.613349
6557.194282
9253.896111
Netherlands
8941.571858
11276.193440
12790.849560
15363.251360
18794.745670
21209.059200
21399.460460
23651.323610
26790.949610
30246.130630
33724.757780
36797.933320
Norway
10095.421720
11653.973040
13450.401510
16361.876470
18965.055510
23311.349390
26298.635310
31540.974800
33965.661150
41283.164330
44683.975250
49357.190170
Poland
4029.329699
4734.253019
5338.752143
6557.152776
8006.506993
9508.141454
8451.531004
9082.351172
7738.881247
10159.583680
12002.239080
15389.924680
Portugal
3068.319867
3774.571743
4727.954889
6361.517993
9022.247417
10172.485720
11753.842910
13039.308760
16207.266630
17641.031560
19970.907870
20509.647770
Romania
3144.613186
3943.370225
4734.997586
6470.866545
8011.414402
9356.397240
9605.314053
9696.273295
6598.409903
7346.547557
7885.360081
10808.475610
Serbia
3581.459448
4981.090891
6289.629157
7991.707066
10522.067490
12980.669560
15181.092700
15870.878510
9325.068238
7914.320304
7236.075251
9786.534714
Slovak Republic
5074.659104
6093.262980
7481.107598
8412.902397
9674.167626
10922.664040
11348.545850
12037.267580
9498.467723
12126.230650
13638.778370
18678.314350
Slovenia
4215.041741
5862.276629
7402.303395
9405.489397
12383.486200
15277.030170
17866.721750
18678.534920
14214.716810
17161.107350
20660.019360
25768.257590
Spain
3834.034742
4564.802410
5693.843879
7993.512294
10638.751310
13236.921170
13926.169970
15764.983130
18603.064520
20445.298960
24835.471660
28821.063700
Sweden
8527.844662
9911.878226
12329.441920
15258.296970
17832.024640
18855.725210
20667.381250
23586.929270
23880.016830
25266.594990
29341.630930
33859.748350
Switzerland
14734.232750
17909.489730
20431.092700
22966.144320
27195.113040
26982.290520
28397.715120
30281.704590
31871.530300
32135.323010
34480.957710
37506.419070
Turkey
1969.100980
2218.754257
2322.869908
2826.356387
3450.696380
4269.122326
4241.356344
5089.043686
5678.348271
6601.429915
6508.085718
8458.276384
United Kingdom
9979.508487
11283.177950
12477.177070
14142.850890
15895.116410
17428.748460
18232.424520
21664.787670
22705.092540
26074.531360
29478.999190
33203.261280
In [27]:
data_europe.describe()
Out[27]:
gdpPercap_1952
gdpPercap_1957
gdpPercap_1962
gdpPercap_1967
gdpPercap_1972
gdpPercap_1977
gdpPercap_1982
gdpPercap_1987
gdpPercap_1992
gdpPercap_1997
gdpPercap_2002
gdpPercap_2007
count
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
30.000000
mean
5661.057435
6963.012816
8365.486814
10143.823757
12479.575246
14283.979110
15617.896551
17214.310727
17061.568084
19076.781802
21711.732422
25054.481636
std
3114.060493
3677.950146
4199.193906
4724.983889
5509.691411
5874.464896
6453.234827
7482.957960
9109.804361
10065.457716
11197.355517
11800.339811
min
973.533195
1353.989176
1709.683679
2172.352423
2860.169750
3528.481305
3630.880722
3738.932735
2497.437901
3193.054604
4604.211737
5937.029526
25%
3241.132406
4394.874315
5373.536612
6657.939047
9057.708095
10360.030300
11449.870115
12274.570680
8667.113214
9946.599306
11721.851483
14811.898210
50%
5142.469716
6066.721495
7515.733738
9366.067033
12326.379990
14225.754515
15322.824720
16215.485895
17550.155945
19596.498550
23674.863230
28054.065790
75%
7236.794919
9597.220820
10931.085347
13277.182057
16523.017127
19052.412163
20901.729730
23321.587723
25034.243045
27189.530312
30373.363307
33817.962533
max
14734.232750
17909.489730
20431.092700
22966.144320
27195.113040
26982.290520
28397.715120
31540.974800
33965.661150
41283.164330
44683.975250
49357.190170
In [28]:
help(data_americas.head)
Help on method head in module pandas.core.generic:
head(n=5) method of pandas.core.frame.DataFrame instance
Return the first `n` rows.
This function returns the first `n` rows for the object based
on position. It is useful for quickly testing if your object
has the right type of data in it.
Parameters
----------
n : int, default 5
Number of rows to select.
Returns
-------
obj_head : type of caller
The first `n` rows of the caller object.
See Also
--------
pandas.DataFrame.tail: Returns the last `n` rows.
Examples
--------
>>> df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
... 'monkey', 'parrot', 'shark', 'whale', 'zebra']})
>>> df
animal
0 alligator
1 bee
2 falcon
3 lion
4 monkey
5 parrot
6 shark
7 whale
8 zebra
Viewing the first 5 lines
>>> df.head()
animal
0 alligator
1 bee
2 falcon
3 lion
4 monkey
Viewing the first `n` lines (three in this case)
>>> df.head(3)
animal
0 alligator
1 bee
2 falcon
In [30]:
data_americas.head()
Out[30]:
continent
country
gdpPercap_1952
gdpPercap_1957
gdpPercap_1962
gdpPercap_1967
gdpPercap_1972
gdpPercap_1977
gdpPercap_1982
gdpPercap_1987
gdpPercap_1992
gdpPercap_1997
gdpPercap_2002
gdpPercap_2007
0
Americas
Argentina
5911.315053
6856.856212
7133.166023
8052.953021
9443.038526
10079.026740
8997.897412
9139.671389
9308.418710
10967.281950
8797.640716
12779.379640
1
Americas
Bolivia
2677.326347
2127.686326
2180.972546
2586.886053
2980.331339
3548.097832
3156.510452
2753.691490
2961.699694
3326.143191
3413.262690
3822.137084
2
Americas
Brazil
2108.944355
2487.365989
3336.585802
3429.864357
4985.711467
6660.118654
7030.835878
7807.095818
6950.283021
7957.980824
8131.212843
9065.800825
3
Americas
Canada
11367.161120
12489.950060
13462.485550
16076.588030
18970.570860
22090.883060
22898.792140
26626.515030
26342.884260
28954.925890
33328.965070
36319.235010
4
Americas
Chile
3939.978789
4315.622723
4519.094331
5106.654313
5494.024437
4756.763836
5095.665738
5547.063754
7596.125964
10118.053180
10778.783850
13171.638850
In [31]:
data_americas.tail()
Out[31]:
continent
country
gdpPercap_1952
gdpPercap_1957
gdpPercap_1962
gdpPercap_1967
gdpPercap_1972
gdpPercap_1977
gdpPercap_1982
gdpPercap_1987
gdpPercap_1992
gdpPercap_1997
gdpPercap_2002
gdpPercap_2007
20
Americas
Puerto Rico
3081.959785
3907.156189
5108.344630
6929.277714
9123.041742
9770.524921
10330.989150
12281.341910
14641.587110
16999.433300
18855.606180
19328.70901
21
Americas
Trinidad and Tobago
3023.271928
4100.393400
4997.523971
5621.368472
6619.551419
7899.554209
9119.528607
7388.597823
7370.990932
8792.573126
11460.600230
18008.50924
22
Americas
United States
13990.482080
14847.127120
16173.145860
19530.365570
21806.035940
24072.632130
25009.559140
29884.350410
32003.932240
35767.433030
39097.099550
42951.65309
23
Americas
Uruguay
5716.766744
6150.772969
5603.357717
5444.619620
5703.408898
6504.339663
6920.223051
7452.398969
8137.004775
9230.240708
7727.002004
10611.46299
24
Americas
Venezuela
7689.799761
9802.466526
8422.974165
9541.474188
10505.259660
13143.950950
11152.410110
9883.584648
10733.926310
10165.495180
8605.047831
11415.80569
In [32]:
data_americas_flipped = data_americas.T
data_americas_flipped.tail(3)
Out[32]:
0
1
2
3
4
5
6
7
8
9
...
15
16
17
18
19
20
21
22
23
24
gdpPercap_1997
10967.3
3326.14
7957.98
28954.9
10118.1
6117.36
6677.05
5431.99
3614.1
7429.46
...
9767.3
2253.02
7113.69
4247.4
5838.35
16999.4
8792.57
35767.4
9230.24
10165.5
gdpPercap_2002
8797.64
3413.26
8131.21
33329
10778.8
5755.26
7723.45
6340.65
4563.81
5773.04
...
10742.4
2474.55
7356.03
3783.67
5909.02
18855.6
11460.6
39097.1
7727
8605.05
gdpPercap_2007
12779.4
3822.14
9065.8
36319.2
13171.6
7006.58
9645.06
8948.1
6025.37
6873.26
...
11977.6
2749.32
9809.19
4172.84
7408.91
19328.7
18008.5
42951.7
10611.5
11415.8
3 rows × 25 columns
In [37]:
help(data_americas_flipped.to_csv)
Help on method to_csv in module pandas.core.frame:
to_csv(path_or_buf=None, sep=',', na_rep='', float_format=None, columns=None, header=True, index=True, index_label=None, mode='w', encoding=None, compression=None, quoting=None, quotechar='"', line_terminator='\n', chunksize=None, tupleize_cols=None, date_format=None, doublequote=True, escapechar=None, decimal='.') method of pandas.core.frame.DataFrame instance
Write DataFrame to a comma-separated values (csv) file
Parameters
----------
path_or_buf : string or file handle, default None
File path or object, if None is provided the result is returned as
a string.
sep : character, default ','
Field delimiter for the output file.
na_rep : string, default ''
Missing data representation
float_format : string, default None
Format string for floating point numbers
columns : sequence, optional
Columns to write
header : boolean or list of string, default True
Write out the column names. If a list of strings is given it is
assumed to be aliases for the column names
index : boolean, default True
Write row names (index)
index_label : string or sequence, or False, default None
Column label for index column(s) if desired. If None is given, and
`header` and `index` are True, then the index names are used. A
sequence should be given if the DataFrame uses MultiIndex. If
False do not print fields for index names. Use index_label=False
for easier importing in R
mode : str
Python write mode, default 'w'
encoding : string, optional
A string representing the encoding to use in the output file,
defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
compression : string, optional
A string representing the compression to use in the output file.
Allowed values are 'gzip', 'bz2', 'zip', 'xz'. This input is only
used when the first argument is a filename.
line_terminator : string, default ``'\n'``
The newline character or character sequence to use in the output
file
quoting : optional constant from csv module
defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`
then floats are converted to strings and thus csv.QUOTE_NONNUMERIC
will treat them as non-numeric
quotechar : string (length 1), default '\"'
character used to quote fields
doublequote : boolean, default True
Control quoting of `quotechar` inside a field
escapechar : string (length 1), default None
character used to escape `sep` and `quotechar` when appropriate
chunksize : int or None
rows to write at a time
tupleize_cols : boolean, default False
.. deprecated:: 0.21.0
This argument will be removed and will always write each row
of the multi-index as a separate row in the CSV file.
Write MultiIndex columns as a list of tuples (if True) or in
the new, expanded format, where each MultiIndex column is a row
in the CSV (if False).
date_format : string, default None
Format string for datetime objects
decimal: string, default '.'
Character recognized as decimal separator. E.g. use ',' for
European data
In [39]:
data_americas_flipped.to_csv('data/data_americas_flipped.csv')
In [40]:
ls 'data'
data_americas_flipped.csv gapminder_gdp_asia.csv
gapminder_all.csv gapminder_gdp_europe.csv
gapminder_gdp_africa.csv gapminder_gdp_oceania.csv
gapminder_gdp_americas.csv
In [ ]:
Content source: juancarlosqr/datascience
Similar notebooks: