pwd
'/Users/suarezc/Desktop/Bootcamp_2021/Untitled Folder'
import numpy as np
import pandas as pd
data = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_oceania.csv')
type(data)
data
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 | Australia | 10039.59564 | 10949.64959 | 12217.22686 | 14526.12465 | 16788.62948 | 18334.19751 | 19477.00928 | 21888.88903 | 23424.76683 | 26997.93657 | 30687.75473 | 34435.36744 |
1 | New Zealand | 10556.57566 | 12247.39532 | 13175.67800 | 14463.91893 | 16046.03728 | 16233.71770 | 17632.41040 | 19007.19129 | 18363.32494 | 21050.41377 | 23189.80135 | 25185.00911 |
data = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_oceania.csv', index_col = 'country')
data
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 | ||||||||||||
Australia | 10039.59564 | 10949.64959 | 12217.22686 | 14526.12465 | 16788.62948 | 18334.19751 | 19477.00928 | 21888.88903 | 23424.76683 | 26997.93657 | 30687.75473 | 34435.36744 |
New Zealand | 10556.57566 | 12247.39532 | 13175.67800 | 14463.91893 | 16046.03728 | 16233.71770 | 17632.41040 | 19007.19129 | 18363.32494 | 21050.41377 | 23189.80135 | 25185.00911 |
data.columns
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')
data.T
country | Australia | New Zealand |
---|---|---|
gdpPercap_1952 | 10039.59564 | 10556.57566 |
gdpPercap_1957 | 10949.64959 | 12247.39532 |
gdpPercap_1962 | 12217.22686 | 13175.67800 |
gdpPercap_1967 | 14526.12465 | 14463.91893 |
gdpPercap_1972 | 16788.62948 | 16046.03728 |
gdpPercap_1977 | 18334.19751 | 16233.71770 |
gdpPercap_1982 | 19477.00928 | 17632.41040 |
gdpPercap_1987 | 21888.88903 | 19007.19129 |
gdpPercap_1992 | 23424.76683 | 18363.32494 |
gdpPercap_1997 | 26997.93657 | 21050.41377 |
gdpPercap_2002 | 30687.75473 | 23189.80135 |
gdpPercap_2007 | 34435.36744 | 25185.00911 |
data
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 | ||||||||||||
Australia | 10039.59564 | 10949.64959 | 12217.22686 | 14526.12465 | 16788.62948 | 18334.19751 | 19477.00928 | 21888.88903 | 23424.76683 | 26997.93657 | 30687.75473 | 34435.36744 |
New Zealand | 10556.57566 | 12247.39532 | 13175.67800 | 14463.91893 | 16046.03728 | 16233.71770 | 17632.41040 | 19007.19129 | 18363.32494 | 21050.41377 | 23189.80135 | 25185.00911 |
data.describe()
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 | 2.000000 | 2.000000 | 2.000000 | 2.000000 | 2.00000 | 2.000000 | 2.000000 | 2.000000 | 2.000000 | 2.000000 | 2.000000 | 2.000000 |
mean | 10298.085650 | 11598.522455 | 12696.452430 | 14495.021790 | 16417.33338 | 17283.957605 | 18554.709840 | 20448.040160 | 20894.045885 | 24024.175170 | 26938.778040 | 29810.188275 |
std | 365.560078 | 917.644806 | 677.727301 | 43.986086 | 525.09198 | 1485.263517 | 1304.328377 | 2037.668013 | 3578.979883 | 4205.533703 | 5301.853680 | 6540.991104 |
min | 10039.595640 | 10949.649590 | 12217.226860 | 14463.918930 | 16046.03728 | 16233.717700 | 17632.410400 | 19007.191290 | 18363.324940 | 21050.413770 | 23189.801350 | 25185.009110 |
25% | 10168.840645 | 11274.086022 | 12456.839645 | 14479.470360 | 16231.68533 | 16758.837652 | 18093.560120 | 19727.615725 | 19628.685412 | 22537.294470 | 25064.289695 | 27497.598692 |
50% | 10298.085650 | 11598.522455 | 12696.452430 | 14495.021790 | 16417.33338 | 17283.957605 | 18554.709840 | 20448.040160 | 20894.045885 | 24024.175170 | 26938.778040 | 29810.188275 |
75% | 10427.330655 | 11922.958888 | 12936.065215 | 14510.573220 | 16602.98143 | 17809.077558 | 19015.859560 | 21168.464595 | 22159.406358 | 25511.055870 | 28813.266385 | 32122.777858 |
max | 10556.575660 | 12247.395320 | 13175.678000 | 14526.124650 | 16788.62948 | 18334.197510 | 19477.009280 | 21888.889030 | 23424.766830 | 26997.936570 | 30687.754730 | 34435.367440 |
/Users/suarezc
data_americas = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_americas.csv', index_col = 'country')
data_americas
continent | 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 | |||||||||||||
Argentina | Americas | 5911.315053 | 6856.856212 | 7133.166023 | 8052.953021 | 9443.038526 | 10079.026740 | 8997.897412 | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | Americas | 2677.326347 | 2127.686326 | 2180.972546 | 2586.886053 | 2980.331339 | 3548.097832 | 3156.510452 | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | Americas | 2108.944355 | 2487.365989 | 3336.585802 | 3429.864357 | 4985.711467 | 6660.118654 | 7030.835878 | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | Americas | 11367.161120 | 12489.950060 | 13462.485550 | 16076.588030 | 18970.570860 | 22090.883060 | 22898.792140 | 26626.515030 | 26342.884260 | 28954.925890 | 33328.965070 | 36319.235010 |
Chile | Americas | 3939.978789 | 4315.622723 | 4519.094331 | 5106.654313 | 5494.024437 | 4756.763836 | 5095.665738 | 5547.063754 | 7596.125964 | 10118.053180 | 10778.783850 | 13171.638850 |
Colombia | Americas | 2144.115096 | 2323.805581 | 2492.351109 | 2678.729839 | 3264.660041 | 3815.807870 | 4397.575659 | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | Americas | 2627.009471 | 2990.010802 | 3460.937025 | 4161.727834 | 5118.146939 | 5926.876967 | 5262.734751 | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Cuba | Americas | 5586.538780 | 6092.174359 | 5180.755910 | 5690.268015 | 5305.445256 | 6380.494966 | 7316.918107 | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | Americas | 1397.717137 | 1544.402995 | 1662.137359 | 1653.723003 | 2189.874499 | 2681.988900 | 2861.092386 | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | Americas | 3522.110717 | 3780.546651 | 4086.114078 | 4579.074215 | 5280.994710 | 6679.623260 | 7213.791267 | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | Americas | 3048.302900 | 3421.523218 | 3776.803627 | 4358.595393 | 4520.246008 | 5138.922374 | 4098.344175 | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | Americas | 2428.237769 | 2617.155967 | 2750.364446 | 3242.531147 | 4031.408271 | 4879.992748 | 4820.494790 | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | Americas | 1840.366939 | 1726.887882 | 1796.589032 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | Americas | 2194.926204 | 2220.487682 | 2291.156835 | 2538.269358 | 2529.842345 | 3203.208066 | 3121.760794 | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Jamaica | Americas | 2898.530881 | 4756.525781 | 5246.107524 | 6124.703451 | 7433.889293 | 6650.195573 | 6068.051350 | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | Americas | 3478.125529 | 4131.546641 | 4581.609385 | 5754.733883 | 6809.406690 | 7674.929108 | 9611.147541 | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Nicaragua | Americas | 3112.363948 | 3457.415947 | 3634.364406 | 4643.393534 | 4688.593267 | 5486.371089 | 3470.338156 | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | Americas | 2480.380334 | 2961.800905 | 3536.540301 | 4421.009084 | 5364.249663 | 5351.912144 | 7009.601598 | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | Americas | 1952.308701 | 2046.154706 | 2148.027146 | 2299.376311 | 2523.337977 | 3248.373311 | 4258.503604 | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | Americas | 3758.523437 | 4245.256698 | 4957.037982 | 5788.093330 | 5937.827283 | 6281.290855 | 6434.501797 | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | Americas | 3081.959785 | 3907.156189 | 5108.344630 | 6929.277714 | 9123.041742 | 9770.524921 | 10330.989150 | 12281.341910 | 14641.587110 | 16999.433300 | 18855.606180 | 19328.709010 |
Trinidad and Tobago | Americas | 3023.271928 | 4100.393400 | 4997.523971 | 5621.368472 | 6619.551419 | 7899.554209 | 9119.528607 | 7388.597823 | 7370.990932 | 8792.573126 | 11460.600230 | 18008.509240 |
United States | Americas | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
Uruguay | Americas | 5716.766744 | 6150.772969 | 5603.357717 | 5444.619620 | 5703.408898 | 6504.339663 | 6920.223051 | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.462990 |
Venezuela | Americas | 7689.799761 | 9802.466526 | 8422.974165 | 9541.474188 | 10505.259660 | 13143.950950 | 11152.410110 | 9883.584648 | 10733.926310 | 10165.495180 | 8605.047831 | 11415.805690 |
data_americas.describe()
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 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 |
mean | 4079.062552 | 4616.043733 | 4901.541870 | 5668.253496 | 6491.334139 | 7352.007126 | 7506.737088 | 7793.400261 | 8044.934406 | 8889.300863 | 9287.677107 | 11003.031625 |
std | 3001.727522 | 3312.381083 | 3421.740569 | 4160.885560 | 4754.404329 | 5355.602518 | 5530.490471 | 6665.039509 | 7047.089191 | 7874.225145 | 8895.817785 | 9713.209302 |
min | 1397.717137 | 1544.402995 | 1662.137359 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
25% | 2428.237769 | 2487.365989 | 2750.364446 | 3242.531147 | 4031.408271 | 4756.763836 | 4258.503604 | 4140.442097 | 4439.450840 | 4684.313807 | 4858.347495 | 5728.353514 |
50% | 3048.302900 | 3780.546651 | 4086.114078 | 4643.393534 | 5305.445256 | 6281.290855 | 6434.501797 | 6360.943444 | 6618.743050 | 7113.692252 | 6994.774861 | 8948.102923 |
75% | 3939.978789 | 4756.525781 | 5180.755910 | 5788.093330 | 6809.406690 | 7674.929108 | 8997.897412 | 7807.095818 | 8137.004775 | 9767.297530 | 8797.640716 | 11977.574960 |
max | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
data_americas.head(n=3)
continent | 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 | |||||||||||||
Argentina | Americas | 5911.315053 | 6856.856212 | 7133.166023 | 8052.953021 | 9443.038526 | 10079.026740 | 8997.897412 | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | Americas | 2677.326347 | 2127.686326 | 2180.972546 | 2586.886053 | 2980.331339 | 3548.097832 | 3156.510452 | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | Americas | 2108.944355 | 2487.365989 | 3336.585802 | 3429.864357 | 4985.711467 | 6660.118654 | 7030.835878 | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
data_americas.T.tail(n=3).T
gdpPercap_1997 | gdpPercap_2002 | gdpPercap_2007 | |
---|---|---|---|
country | |||
Argentina | 10967.28195 | 8797.640716 | 12779.37964 |
Bolivia | 3326.143191 | 3413.26269 | 3822.137084 |
Brazil | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | 28954.92589 | 33328.96507 | 36319.23501 |
Chile | 10118.05318 | 10778.78385 | 13171.63885 |
Colombia | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | 6677.045314 | 7723.447195 | 9645.06142 |
Cuba | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | 3160.454906 | 3099.72866 | 3548.330846 |
Jamaica | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | 9767.29753 | 10742.44053 | 11977.57496 |
Nicaragua | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | 16999.4333 | 18855.60618 | 19328.70901 |
Trinidad and Tobago | 8792.573126 | 11460.60023 | 18008.50924 |
United States | 35767.43303 | 39097.09955 | 42951.65309 |
Uruguay | 9230.240708 | 7727.002004 | 10611.46299 |
Venezuela | 10165.49518 | 8605.047831 | 11415.80569 |
data_americas.iloc[0,1]
5911.315053
data_americas.loc['Argentina', 'gdpPercap_1952']
5911.315053
data_americas
continent | 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 | |||||||||||||
Argentina | Americas | 5911.315053 | 6856.856212 | 7133.166023 | 8052.953021 | 9443.038526 | 10079.026740 | 8997.897412 | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | Americas | 2677.326347 | 2127.686326 | 2180.972546 | 2586.886053 | 2980.331339 | 3548.097832 | 3156.510452 | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | Americas | 2108.944355 | 2487.365989 | 3336.585802 | 3429.864357 | 4985.711467 | 6660.118654 | 7030.835878 | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | Americas | 11367.161120 | 12489.950060 | 13462.485550 | 16076.588030 | 18970.570860 | 22090.883060 | 22898.792140 | 26626.515030 | 26342.884260 | 28954.925890 | 33328.965070 | 36319.235010 |
Chile | Americas | 3939.978789 | 4315.622723 | 4519.094331 | 5106.654313 | 5494.024437 | 4756.763836 | 5095.665738 | 5547.063754 | 7596.125964 | 10118.053180 | 10778.783850 | 13171.638850 |
Colombia | Americas | 2144.115096 | 2323.805581 | 2492.351109 | 2678.729839 | 3264.660041 | 3815.807870 | 4397.575659 | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | Americas | 2627.009471 | 2990.010802 | 3460.937025 | 4161.727834 | 5118.146939 | 5926.876967 | 5262.734751 | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Cuba | Americas | 5586.538780 | 6092.174359 | 5180.755910 | 5690.268015 | 5305.445256 | 6380.494966 | 7316.918107 | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | Americas | 1397.717137 | 1544.402995 | 1662.137359 | 1653.723003 | 2189.874499 | 2681.988900 | 2861.092386 | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | Americas | 3522.110717 | 3780.546651 | 4086.114078 | 4579.074215 | 5280.994710 | 6679.623260 | 7213.791267 | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | Americas | 3048.302900 | 3421.523218 | 3776.803627 | 4358.595393 | 4520.246008 | 5138.922374 | 4098.344175 | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | Americas | 2428.237769 | 2617.155967 | 2750.364446 | 3242.531147 | 4031.408271 | 4879.992748 | 4820.494790 | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | Americas | 1840.366939 | 1726.887882 | 1796.589032 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | Americas | 2194.926204 | 2220.487682 | 2291.156835 | 2538.269358 | 2529.842345 | 3203.208066 | 3121.760794 | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Jamaica | Americas | 2898.530881 | 4756.525781 | 5246.107524 | 6124.703451 | 7433.889293 | 6650.195573 | 6068.051350 | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | Americas | 3478.125529 | 4131.546641 | 4581.609385 | 5754.733883 | 6809.406690 | 7674.929108 | 9611.147541 | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Nicaragua | Americas | 3112.363948 | 3457.415947 | 3634.364406 | 4643.393534 | 4688.593267 | 5486.371089 | 3470.338156 | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | Americas | 2480.380334 | 2961.800905 | 3536.540301 | 4421.009084 | 5364.249663 | 5351.912144 | 7009.601598 | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | Americas | 1952.308701 | 2046.154706 | 2148.027146 | 2299.376311 | 2523.337977 | 3248.373311 | 4258.503604 | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | Americas | 3758.523437 | 4245.256698 | 4957.037982 | 5788.093330 | 5937.827283 | 6281.290855 | 6434.501797 | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | Americas | 3081.959785 | 3907.156189 | 5108.344630 | 6929.277714 | 9123.041742 | 9770.524921 | 10330.989150 | 12281.341910 | 14641.587110 | 16999.433300 | 18855.606180 | 19328.709010 |
Trinidad and Tobago | Americas | 3023.271928 | 4100.393400 | 4997.523971 | 5621.368472 | 6619.551419 | 7899.554209 | 9119.528607 | 7388.597823 | 7370.990932 | 8792.573126 | 11460.600230 | 18008.509240 |
United States | Americas | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
Uruguay | Americas | 5716.766744 | 6150.772969 | 5603.357717 | 5444.619620 | 5703.408898 | 6504.339663 | 6920.223051 | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.462990 |
Venezuela | Americas | 7689.799761 | 9802.466526 | 8422.974165 | 9541.474188 | 10505.259660 | 13143.950950 | 11152.410110 | 9883.584648 | 10733.926310 | 10165.495180 | 8605.047831 | 11415.805690 |
data_americas = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_americas.csv', index_col = 'continent')
data_americas
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 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
continent | |||||||||||||
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 |
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 |
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 |
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 |
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 |
Americas | Colombia | 2144.115096 | 2323.805581 | 2492.351109 | 2678.729839 | 3264.660041 | 3815.807870 | 4397.575659 | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Americas | Costa Rica | 2627.009471 | 2990.010802 | 3460.937025 | 4161.727834 | 5118.146939 | 5926.876967 | 5262.734751 | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Americas | Cuba | 5586.538780 | 6092.174359 | 5180.755910 | 5690.268015 | 5305.445256 | 6380.494966 | 7316.918107 | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Americas | Dominican Republic | 1397.717137 | 1544.402995 | 1662.137359 | 1653.723003 | 2189.874499 | 2681.988900 | 2861.092386 | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Americas | Ecuador | 3522.110717 | 3780.546651 | 4086.114078 | 4579.074215 | 5280.994710 | 6679.623260 | 7213.791267 | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
Americas | El Salvador | 3048.302900 | 3421.523218 | 3776.803627 | 4358.595393 | 4520.246008 | 5138.922374 | 4098.344175 | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Americas | Guatemala | 2428.237769 | 2617.155967 | 2750.364446 | 3242.531147 | 4031.408271 | 4879.992748 | 4820.494790 | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Americas | Haiti | 1840.366939 | 1726.887882 | 1796.589032 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Americas | Honduras | 2194.926204 | 2220.487682 | 2291.156835 | 2538.269358 | 2529.842345 | 3203.208066 | 3121.760794 | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Americas | Jamaica | 2898.530881 | 4756.525781 | 5246.107524 | 6124.703451 | 7433.889293 | 6650.195573 | 6068.051350 | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Americas | Mexico | 3478.125529 | 4131.546641 | 4581.609385 | 5754.733883 | 6809.406690 | 7674.929108 | 9611.147541 | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Americas | Nicaragua | 3112.363948 | 3457.415947 | 3634.364406 | 4643.393534 | 4688.593267 | 5486.371089 | 3470.338156 | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Americas | Panama | 2480.380334 | 2961.800905 | 3536.540301 | 4421.009084 | 5364.249663 | 5351.912144 | 7009.601598 | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Americas | Paraguay | 1952.308701 | 2046.154706 | 2148.027146 | 2299.376311 | 2523.337977 | 3248.373311 | 4258.503604 | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Americas | Peru | 3758.523437 | 4245.256698 | 4957.037982 | 5788.093330 | 5937.827283 | 6281.290855 | 6434.501797 | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
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.709010 |
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.509240 |
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.653090 |
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.462990 |
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.805690 |
data_americas.loc['Americas', 'country']
continent Americas Argentina Americas Bolivia Americas Brazil Americas Canada Americas Chile Americas Colombia Americas Costa Rica Americas Cuba Americas Dominican Republic Americas Ecuador Americas El Salvador Americas Guatemala Americas Haiti Americas Honduras Americas Jamaica Americas Mexico Americas Nicaragua Americas Panama Americas Paraguay Americas Peru Americas Puerto Rico Americas Trinidad and Tobago Americas United States Americas Uruguay Americas Venezuela Name: country, dtype: object
type(data_americas.describe())
pandas.core.frame.DataFrame
data_americas = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_americas.csv', index_col = 'country')
americas_statistics = data_americas.describe()
americas_statistics
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 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 |
mean | 4079.062552 | 4616.043733 | 4901.541870 | 5668.253496 | 6491.334139 | 7352.007126 | 7506.737088 | 7793.400261 | 8044.934406 | 8889.300863 | 9287.677107 | 11003.031625 |
std | 3001.727522 | 3312.381083 | 3421.740569 | 4160.885560 | 4754.404329 | 5355.602518 | 5530.490471 | 6665.039509 | 7047.089191 | 7874.225145 | 8895.817785 | 9713.209302 |
min | 1397.717137 | 1544.402995 | 1662.137359 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
25% | 2428.237769 | 2487.365989 | 2750.364446 | 3242.531147 | 4031.408271 | 4756.763836 | 4258.503604 | 4140.442097 | 4439.450840 | 4684.313807 | 4858.347495 | 5728.353514 |
50% | 3048.302900 | 3780.546651 | 4086.114078 | 4643.393534 | 5305.445256 | 6281.290855 | 6434.501797 | 6360.943444 | 6618.743050 | 7113.692252 | 6994.774861 | 8948.102923 |
75% | 3939.978789 | 4756.525781 | 5180.755910 | 5788.093330 | 6809.406690 | 7674.929108 | 8997.897412 | 7807.095818 | 8137.004775 | 9767.297530 | 8797.640716 | 11977.574960 |
max | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
americas_statistics.loc['count']
gdpPercap_1952 25.0 gdpPercap_1957 25.0 gdpPercap_1962 25.0 gdpPercap_1967 25.0 gdpPercap_1972 25.0 gdpPercap_1977 25.0 gdpPercap_1982 25.0 gdpPercap_1987 25.0 gdpPercap_1992 25.0 gdpPercap_1997 25.0 gdpPercap_2002 25.0 gdpPercap_2007 25.0 Name: count, dtype: float64
data_americas.gdpPercap_1952['Mexico']
3478.125529
data_americas.loc['Mexico', :]
continent Americas gdpPercap_1952 3478.125529 gdpPercap_1957 4131.546641 gdpPercap_1962 4581.609385 gdpPercap_1967 5754.733883 gdpPercap_1972 6809.40669 gdpPercap_1977 7674.929108 gdpPercap_1982 9611.147541 gdpPercap_1987 8688.156003 gdpPercap_1992 9472.384295 gdpPercap_1997 9767.29753 gdpPercap_2002 10742.44053 gdpPercap_2007 11977.57496 Name: Mexico, dtype: object
data_americas.loc[:, 'gdpPercap_1952']
country Argentina 5911.315053 Bolivia 2677.326347 Brazil 2108.944355 Canada 11367.161120 Chile 3939.978789 Colombia 2144.115096 Costa Rica 2627.009471 Cuba 5586.538780 Dominican Republic 1397.717137 Ecuador 3522.110717 El Salvador 3048.302900 Guatemala 2428.237769 Haiti 1840.366939 Honduras 2194.926204 Jamaica 2898.530881 Mexico 3478.125529 Nicaragua 3112.363948 Panama 2480.380334 Paraguay 1952.308701 Peru 3758.523437 Puerto Rico 3081.959785 Trinidad and Tobago 3023.271928 United States 13990.482080 Uruguay 5716.766744 Venezuela 7689.799761 Name: gdpPercap_1952, dtype: float64
data_americas.loc['Haiti' : 'Mexico', 'gdpPercap_1952' : 'gdpPercap_1962']
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
country | |||
Haiti | 1840.366939 | 1726.887882 | 1796.589032 |
Honduras | 2194.926204 | 2220.487682 | 2291.156835 |
Jamaica | 2898.530881 | 4756.525781 | 5246.107524 |
Mexico | 3478.125529 | 4131.546641 | 4581.609385 |
data_americas
continent | 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 | |||||||||||||
Argentina | Americas | 5911.315053 | 6856.856212 | 7133.166023 | 8052.953021 | 9443.038526 | 10079.026740 | 8997.897412 | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | Americas | 2677.326347 | 2127.686326 | 2180.972546 | 2586.886053 | 2980.331339 | 3548.097832 | 3156.510452 | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | Americas | 2108.944355 | 2487.365989 | 3336.585802 | 3429.864357 | 4985.711467 | 6660.118654 | 7030.835878 | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | Americas | 11367.161120 | 12489.950060 | 13462.485550 | 16076.588030 | 18970.570860 | 22090.883060 | 22898.792140 | 26626.515030 | 26342.884260 | 28954.925890 | 33328.965070 | 36319.235010 |
Chile | Americas | 3939.978789 | 4315.622723 | 4519.094331 | 5106.654313 | 5494.024437 | 4756.763836 | 5095.665738 | 5547.063754 | 7596.125964 | 10118.053180 | 10778.783850 | 13171.638850 |
Colombia | Americas | 2144.115096 | 2323.805581 | 2492.351109 | 2678.729839 | 3264.660041 | 3815.807870 | 4397.575659 | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | Americas | 2627.009471 | 2990.010802 | 3460.937025 | 4161.727834 | 5118.146939 | 5926.876967 | 5262.734751 | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Cuba | Americas | 5586.538780 | 6092.174359 | 5180.755910 | 5690.268015 | 5305.445256 | 6380.494966 | 7316.918107 | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | Americas | 1397.717137 | 1544.402995 | 1662.137359 | 1653.723003 | 2189.874499 | 2681.988900 | 2861.092386 | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | Americas | 3522.110717 | 3780.546651 | 4086.114078 | 4579.074215 | 5280.994710 | 6679.623260 | 7213.791267 | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | Americas | 3048.302900 | 3421.523218 | 3776.803627 | 4358.595393 | 4520.246008 | 5138.922374 | 4098.344175 | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | Americas | 2428.237769 | 2617.155967 | 2750.364446 | 3242.531147 | 4031.408271 | 4879.992748 | 4820.494790 | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | Americas | 1840.366939 | 1726.887882 | 1796.589032 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | Americas | 2194.926204 | 2220.487682 | 2291.156835 | 2538.269358 | 2529.842345 | 3203.208066 | 3121.760794 | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Jamaica | Americas | 2898.530881 | 4756.525781 | 5246.107524 | 6124.703451 | 7433.889293 | 6650.195573 | 6068.051350 | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | Americas | 3478.125529 | 4131.546641 | 4581.609385 | 5754.733883 | 6809.406690 | 7674.929108 | 9611.147541 | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Nicaragua | Americas | 3112.363948 | 3457.415947 | 3634.364406 | 4643.393534 | 4688.593267 | 5486.371089 | 3470.338156 | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | Americas | 2480.380334 | 2961.800905 | 3536.540301 | 4421.009084 | 5364.249663 | 5351.912144 | 7009.601598 | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | Americas | 1952.308701 | 2046.154706 | 2148.027146 | 2299.376311 | 2523.337977 | 3248.373311 | 4258.503604 | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | Americas | 3758.523437 | 4245.256698 | 4957.037982 | 5788.093330 | 5937.827283 | 6281.290855 | 6434.501797 | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | Americas | 3081.959785 | 3907.156189 | 5108.344630 | 6929.277714 | 9123.041742 | 9770.524921 | 10330.989150 | 12281.341910 | 14641.587110 | 16999.433300 | 18855.606180 | 19328.709010 |
Trinidad and Tobago | Americas | 3023.271928 | 4100.393400 | 4997.523971 | 5621.368472 | 6619.551419 | 7899.554209 | 9119.528607 | 7388.597823 | 7370.990932 | 8792.573126 | 11460.600230 | 18008.509240 |
United States | Americas | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
Uruguay | Americas | 5716.766744 | 6150.772969 | 5603.357717 | 5444.619620 | 5703.408898 | 6504.339663 | 6920.223051 | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.462990 |
Venezuela | Americas | 7689.799761 | 9802.466526 | 8422.974165 | 9541.474188 | 10505.259660 | 13143.950950 | 11152.410110 | 9883.584648 | 10733.926310 | 10165.495180 | 8605.047831 | 11415.805690 |
subset_americas = data_americas.loc['Haiti' : 'Mexico', 'gdpPercap_1952' : 'gdpPercap_1962']
subset_americas
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
country | |||
Haiti | 1840.366939 | 1726.887882 | 1796.589032 |
Honduras | 2194.926204 | 2220.487682 | 2291.156835 |
Jamaica | 2898.530881 | 4756.525781 | 5246.107524 |
Mexico | 3478.125529 | 4131.546641 | 4581.609385 |
mask = subset_americas > 2000
type(mask)
mask
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
country | |||
Haiti | False | False | False |
Honduras | True | True | True |
Jamaica | True | True | True |
Mexico | True | True | True |
subset_americas[mask]
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
country | |||
Haiti | NaN | NaN | NaN |
Honduras | 2194.926204 | 2220.487682 | 2291.156835 |
Jamaica | 2898.530881 | 4756.525781 | 5246.107524 |
Mexico | 3478.125529 | 4131.546641 | 4581.609385 |
subset_americas[mask].describe()
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
count | 3.000000 | 3.000000 | 3.000000 |
mean | 2857.194205 | 3702.853368 | 4039.624581 |
std | 642.597594 | 1321.251585 | 1550.239994 |
min | 2194.926204 | 2220.487682 | 2291.156835 |
25% | 2546.728543 | 3176.017161 | 3436.383110 |
50% | 2898.530881 | 4131.546641 | 4581.609385 |
75% | 3188.328205 | 4444.036211 | 4913.858454 |
max | 3478.125529 | 4756.525781 | 5246.107524 |
subset_americas.describe()
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
count | 4.000000 | 4.000000 | 4.000000 |
mean | 2602.987388 | 3208.861996 | 3478.865694 |
std | 730.597153 | 1462.844399 | 1691.143049 |
min | 1840.366939 | 1726.887882 | 1796.589032 |
25% | 2106.286388 | 2097.087732 | 2167.514884 |
50% | 2546.728543 | 3176.017161 | 3436.383110 |
75% | 3043.429543 | 4287.791426 | 4747.733920 |
max | 3478.125529 | 4756.525781 | 5246.107524 |
subset_americas = subset_americas[mask]
subset_americas
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
country | |||
Haiti | NaN | NaN | NaN |
Honduras | 2194.926204 | 2220.487682 | 2291.156835 |
Jamaica | 2898.530881 | 4756.525781 | 5246.107524 |
Mexico | 3478.125529 | 4131.546641 | 4581.609385 |
data_americas
continent | 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 | |||||||||||||
Argentina | Americas | 5911.315053 | 6856.856212 | 7133.166023 | 8052.953021 | 9443.038526 | 10079.026740 | 8997.897412 | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | Americas | 2677.326347 | 2127.686326 | 2180.972546 | 2586.886053 | 2980.331339 | 3548.097832 | 3156.510452 | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | Americas | 2108.944355 | 2487.365989 | 3336.585802 | 3429.864357 | 4985.711467 | 6660.118654 | 7030.835878 | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | Americas | 11367.161120 | 12489.950060 | 13462.485550 | 16076.588030 | 18970.570860 | 22090.883060 | 22898.792140 | 26626.515030 | 26342.884260 | 28954.925890 | 33328.965070 | 36319.235010 |
Chile | Americas | 3939.978789 | 4315.622723 | 4519.094331 | 5106.654313 | 5494.024437 | 4756.763836 | 5095.665738 | 5547.063754 | 7596.125964 | 10118.053180 | 10778.783850 | 13171.638850 |
Colombia | Americas | 2144.115096 | 2323.805581 | 2492.351109 | 2678.729839 | 3264.660041 | 3815.807870 | 4397.575659 | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | Americas | 2627.009471 | 2990.010802 | 3460.937025 | 4161.727834 | 5118.146939 | 5926.876967 | 5262.734751 | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Cuba | Americas | 5586.538780 | 6092.174359 | 5180.755910 | 5690.268015 | 5305.445256 | 6380.494966 | 7316.918107 | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | Americas | 1397.717137 | 1544.402995 | 1662.137359 | 1653.723003 | 2189.874499 | 2681.988900 | 2861.092386 | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | Americas | 3522.110717 | 3780.546651 | 4086.114078 | 4579.074215 | 5280.994710 | 6679.623260 | 7213.791267 | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | Americas | 3048.302900 | 3421.523218 | 3776.803627 | 4358.595393 | 4520.246008 | 5138.922374 | 4098.344175 | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | Americas | 2428.237769 | 2617.155967 | 2750.364446 | 3242.531147 | 4031.408271 | 4879.992748 | 4820.494790 | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | Americas | 1840.366939 | 1726.887882 | 1796.589032 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | Americas | 2194.926204 | 2220.487682 | 2291.156835 | 2538.269358 | 2529.842345 | 3203.208066 | 3121.760794 | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Jamaica | Americas | 2898.530881 | 4756.525781 | 5246.107524 | 6124.703451 | 7433.889293 | 6650.195573 | 6068.051350 | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | Americas | 3478.125529 | 4131.546641 | 4581.609385 | 5754.733883 | 6809.406690 | 7674.929108 | 9611.147541 | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Nicaragua | Americas | 3112.363948 | 3457.415947 | 3634.364406 | 4643.393534 | 4688.593267 | 5486.371089 | 3470.338156 | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | Americas | 2480.380334 | 2961.800905 | 3536.540301 | 4421.009084 | 5364.249663 | 5351.912144 | 7009.601598 | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | Americas | 1952.308701 | 2046.154706 | 2148.027146 | 2299.376311 | 2523.337977 | 3248.373311 | 4258.503604 | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | Americas | 3758.523437 | 4245.256698 | 4957.037982 | 5788.093330 | 5937.827283 | 6281.290855 | 6434.501797 | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | Americas | 3081.959785 | 3907.156189 | 5108.344630 | 6929.277714 | 9123.041742 | 9770.524921 | 10330.989150 | 12281.341910 | 14641.587110 | 16999.433300 | 18855.606180 | 19328.709010 |
Trinidad and Tobago | Americas | 3023.271928 | 4100.393400 | 4997.523971 | 5621.368472 | 6619.551419 | 7899.554209 | 9119.528607 | 7388.597823 | 7370.990932 | 8792.573126 | 11460.600230 | 18008.509240 |
United States | Americas | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
Uruguay | Americas | 5716.766744 | 6150.772969 | 5603.357717 | 5444.619620 | 5703.408898 | 6504.339663 | 6920.223051 | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.462990 |
Venezuela | Americas | 7689.799761 | 9802.466526 | 8422.974165 | 9541.474188 | 10505.259660 | 13143.950950 | 11152.410110 | 9883.584648 | 10733.926310 | 10165.495180 | 8605.047831 | 11415.805690 |
data_americas.loc['Mexico', 'gdpPercap_2007']
11977.57496
print(data_americas.iloc[0:2, 0:2])
print(data_americas.loc['Argentina': 'Bolivia', 'gdpPercap_1952':'gdpPercap_1962'])
continent gdpPercap_1952 country Argentina Americas 5911.315053 Bolivia Americas 2677.326347 gdpPercap_1952 gdpPercap_1957 gdpPercap_1962 country Argentina 5911.315053 6856.856212 7133.166023 Bolivia 2677.326347 2127.686326 2180.972546
data_americas.loc[:, 'gdpPercap_1982']
country Argentina 8997.897412 Bolivia 3156.510452 Brazil 7030.835878 Canada 22898.792140 Chile 5095.665738 Colombia 4397.575659 Costa Rica 5262.734751 Cuba 7316.918107 Dominican Republic 2861.092386 Ecuador 7213.791267 El Salvador 4098.344175 Guatemala 4820.494790 Haiti 2011.159549 Honduras 3121.760794 Jamaica 6068.051350 Mexico 9611.147541 Nicaragua 3470.338156 Panama 7009.601598 Paraguay 4258.503604 Peru 6434.501797 Puerto Rico 10330.989150 Trinidad and Tobago 9119.528607 United States 25009.559140 Uruguay 6920.223051 Venezuela 11152.410110 Name: gdpPercap_1982, dtype: float64
data_americas.loc['Mexico', :]
continent Americas gdpPercap_1952 3478.125529 gdpPercap_1957 4131.546641 gdpPercap_1962 4581.609385 gdpPercap_1967 5754.733883 gdpPercap_1972 6809.40669 gdpPercap_1977 7674.929108 gdpPercap_1982 9611.147541 gdpPercap_1987 8688.156003 gdpPercap_1992 9472.384295 gdpPercap_1997 9767.29753 gdpPercap_2002 10742.44053 gdpPercap_2007 11977.57496 Name: Mexico, dtype: object
data_americas.loc[:, 'gdpPercap_1985':]
gdpPercap_1987 | gdpPercap_1992 | gdpPercap_1997 | gdpPercap_2002 | gdpPercap_2007 | |
---|---|---|---|---|---|
country | |||||
Argentina | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | 26626.515030 | 26342.884260 | 28954.925890 | 33328.965070 | 36319.235010 |
Chile | 5547.063754 | 7596.125964 | 10118.053180 | 10778.783850 | 13171.638850 |
Colombia | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Cuba | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Jamaica | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Nicaragua | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | 12281.341910 | 14641.587110 | 16999.433300 | 18855.606180 | 19328.709010 |
Trinidad and Tobago | 7388.597823 | 7370.990932 | 8792.573126 | 11460.600230 | 18008.509240 |
United States | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
Uruguay | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.462990 |
Venezuela | 9883.584648 | 10733.926310 | 10165.495180 | 8605.047831 | 11415.805690 |
data_americas.T.tail(n=5).T
gdpPercap_1987 | gdpPercap_1992 | gdpPercap_1997 | gdpPercap_2002 | gdpPercap_2007 | |
---|---|---|---|---|---|
country | |||||
Argentina | 9139.671389 | 9308.41871 | 10967.28195 | 8797.640716 | 12779.37964 |
Bolivia | 2753.69149 | 2961.699694 | 3326.143191 | 3413.26269 | 3822.137084 |
Brazil | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | 26626.51503 | 26342.88426 | 28954.92589 | 33328.96507 | 36319.23501 |
Chile | 5547.063754 | 7596.125964 | 10118.05318 | 10778.78385 | 13171.63885 |
Colombia | 4903.2191 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.06142 |
Cuba | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | 4140.442097 | 4444.2317 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | 4246.485974 | 4439.45084 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | 3023.096699 | 3081.694603 | 3160.454906 | 3099.72866 | 3548.330846 |
Jamaica | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | 8688.156003 | 9472.384295 | 9767.29753 | 10742.44053 | 11977.57496 |
Nicaragua | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | 7034.779161 | 6618.74305 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | 12281.34191 | 14641.58711 | 16999.4333 | 18855.60618 | 19328.70901 |
Trinidad and Tobago | 7388.597823 | 7370.990932 | 8792.573126 | 11460.60023 | 18008.50924 |
United States | 29884.35041 | 32003.93224 | 35767.43303 | 39097.09955 | 42951.65309 |
Uruguay | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.46299 |
Venezuela | 9883.584648 | 10733.92631 | 10165.49518 | 8605.047831 | 11415.80569 |
data_americas.T.tail(n=5).T == data_americas.loc[:, 'gdpPercap_1985':]
gdpPercap_1987 | gdpPercap_1992 | gdpPercap_1997 | gdpPercap_2002 | gdpPercap_2007 | |
---|---|---|---|---|---|
country | |||||
Argentina | True | True | True | True | True |
Bolivia | True | True | True | True | True |
Brazil | True | True | True | True | True |
Canada | True | True | True | True | True |
Chile | True | True | True | True | True |
Colombia | True | True | True | True | True |
Costa Rica | True | True | True | True | True |
Cuba | True | True | True | True | True |
Dominican Republic | True | True | True | True | True |
Ecuador | True | True | True | True | True |
El Salvador | True | True | True | True | True |
Guatemala | True | True | True | True | True |
Haiti | True | True | True | True | True |
Honduras | True | True | True | True | True |
Jamaica | True | True | True | True | True |
Mexico | True | True | True | True | True |
Nicaragua | True | True | True | True | True |
Panama | True | True | True | True | True |
Paraguay | True | True | True | True | True |
Peru | True | True | True | True | True |
Puerto Rico | True | True | True | True | True |
Trinidad and Tobago | True | True | True | True | True |
United States | True | True | True | True | True |
Uruguay | True | True | True | True | True |
Venezuela | True | True | True | True | True |
mask2 = subset_americas > 4500
np.where(mask2 == True)
(array([2, 2, 3]), array([1, 2, 2]))
subset_americas[mask2]
gdpPercap_1952 | gdpPercap_1957 | gdpPercap_1962 | |
---|---|---|---|
country | |||
Haiti | NaN | NaN | NaN |
Honduras | NaN | NaN | NaN |
Jamaica | NaN | 4756.525781 | 5246.107524 |
Mexico | NaN | NaN | 4581.609385 |
import matplotlib.pyplot as plt
time = [0,1,2,3]
postion = [0, 100, 200, 300]
plt.scatter(time, postion)
plt.xlabel('Time (s)')
plt.ylabel('Position (m)')
plt.show()
#plt. + Tab > see all methods
data_americas = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_americas.csv', index_col = 'country')
data_americas
continent | 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 | |||||||||||||
Argentina | Americas | 5911.315053 | 6856.856212 | 7133.166023 | 8052.953021 | 9443.038526 | 10079.026740 | 8997.897412 | 9139.671389 | 9308.418710 | 10967.281950 | 8797.640716 | 12779.379640 |
Bolivia | Americas | 2677.326347 | 2127.686326 | 2180.972546 | 2586.886053 | 2980.331339 | 3548.097832 | 3156.510452 | 2753.691490 | 2961.699694 | 3326.143191 | 3413.262690 | 3822.137084 |
Brazil | Americas | 2108.944355 | 2487.365989 | 3336.585802 | 3429.864357 | 4985.711467 | 6660.118654 | 7030.835878 | 7807.095818 | 6950.283021 | 7957.980824 | 8131.212843 | 9065.800825 |
Canada | Americas | 11367.161120 | 12489.950060 | 13462.485550 | 16076.588030 | 18970.570860 | 22090.883060 | 22898.792140 | 26626.515030 | 26342.884260 | 28954.925890 | 33328.965070 | 36319.235010 |
Chile | Americas | 3939.978789 | 4315.622723 | 4519.094331 | 5106.654313 | 5494.024437 | 4756.763836 | 5095.665738 | 5547.063754 | 7596.125964 | 10118.053180 | 10778.783850 | 13171.638850 |
Colombia | Americas | 2144.115096 | 2323.805581 | 2492.351109 | 2678.729839 | 3264.660041 | 3815.807870 | 4397.575659 | 4903.219100 | 5444.648617 | 6117.361746 | 5755.259962 | 7006.580419 |
Costa Rica | Americas | 2627.009471 | 2990.010802 | 3460.937025 | 4161.727834 | 5118.146939 | 5926.876967 | 5262.734751 | 5629.915318 | 6160.416317 | 6677.045314 | 7723.447195 | 9645.061420 |
Cuba | Americas | 5586.538780 | 6092.174359 | 5180.755910 | 5690.268015 | 5305.445256 | 6380.494966 | 7316.918107 | 7532.924763 | 5592.843963 | 5431.990415 | 6340.646683 | 8948.102923 |
Dominican Republic | Americas | 1397.717137 | 1544.402995 | 1662.137359 | 1653.723003 | 2189.874499 | 2681.988900 | 2861.092386 | 2899.842175 | 3044.214214 | 3614.101285 | 4563.808154 | 6025.374752 |
Ecuador | Americas | 3522.110717 | 3780.546651 | 4086.114078 | 4579.074215 | 5280.994710 | 6679.623260 | 7213.791267 | 6481.776993 | 7103.702595 | 7429.455877 | 5773.044512 | 6873.262326 |
El Salvador | Americas | 3048.302900 | 3421.523218 | 3776.803627 | 4358.595393 | 4520.246008 | 5138.922374 | 4098.344175 | 4140.442097 | 4444.231700 | 5154.825496 | 5351.568666 | 5728.353514 |
Guatemala | Americas | 2428.237769 | 2617.155967 | 2750.364446 | 3242.531147 | 4031.408271 | 4879.992748 | 4820.494790 | 4246.485974 | 4439.450840 | 4684.313807 | 4858.347495 | 5186.050003 |
Haiti | Americas | 1840.366939 | 1726.887882 | 1796.589032 | 1452.057666 | 1654.456946 | 1874.298931 | 2011.159549 | 1823.015995 | 1456.309517 | 1341.726931 | 1270.364932 | 1201.637154 |
Honduras | Americas | 2194.926204 | 2220.487682 | 2291.156835 | 2538.269358 | 2529.842345 | 3203.208066 | 3121.760794 | 3023.096699 | 3081.694603 | 3160.454906 | 3099.728660 | 3548.330846 |
Jamaica | Americas | 2898.530881 | 4756.525781 | 5246.107524 | 6124.703451 | 7433.889293 | 6650.195573 | 6068.051350 | 6351.237495 | 7404.923685 | 7121.924704 | 6994.774861 | 7320.880262 |
Mexico | Americas | 3478.125529 | 4131.546641 | 4581.609385 | 5754.733883 | 6809.406690 | 7674.929108 | 9611.147541 | 8688.156003 | 9472.384295 | 9767.297530 | 10742.440530 | 11977.574960 |
Nicaragua | Americas | 3112.363948 | 3457.415947 | 3634.364406 | 4643.393534 | 4688.593267 | 5486.371089 | 3470.338156 | 2955.984375 | 2170.151724 | 2253.023004 | 2474.548819 | 2749.320965 |
Panama | Americas | 2480.380334 | 2961.800905 | 3536.540301 | 4421.009084 | 5364.249663 | 5351.912144 | 7009.601598 | 7034.779161 | 6618.743050 | 7113.692252 | 7356.031934 | 9809.185636 |
Paraguay | Americas | 1952.308701 | 2046.154706 | 2148.027146 | 2299.376311 | 2523.337977 | 3248.373311 | 4258.503604 | 3998.875695 | 4196.411078 | 4247.400261 | 3783.674243 | 4172.838464 |
Peru | Americas | 3758.523437 | 4245.256698 | 4957.037982 | 5788.093330 | 5937.827283 | 6281.290855 | 6434.501797 | 6360.943444 | 4446.380924 | 5838.347657 | 5909.020073 | 7408.905561 |
Puerto Rico | Americas | 3081.959785 | 3907.156189 | 5108.344630 | 6929.277714 | 9123.041742 | 9770.524921 | 10330.989150 | 12281.341910 | 14641.587110 | 16999.433300 | 18855.606180 | 19328.709010 |
Trinidad and Tobago | Americas | 3023.271928 | 4100.393400 | 4997.523971 | 5621.368472 | 6619.551419 | 7899.554209 | 9119.528607 | 7388.597823 | 7370.990932 | 8792.573126 | 11460.600230 | 18008.509240 |
United States | Americas | 13990.482080 | 14847.127120 | 16173.145860 | 19530.365570 | 21806.035940 | 24072.632130 | 25009.559140 | 29884.350410 | 32003.932240 | 35767.433030 | 39097.099550 | 42951.653090 |
Uruguay | Americas | 5716.766744 | 6150.772969 | 5603.357717 | 5444.619620 | 5703.408898 | 6504.339663 | 6920.223051 | 7452.398969 | 8137.004775 | 9230.240708 | 7727.002004 | 10611.462990 |
Venezuela | Americas | 7689.799761 | 9802.466526 | 8422.974165 | 9541.474188 | 10505.259660 | 13143.950950 | 11152.410110 | 9883.584648 | 10733.926310 | 10165.495180 | 8605.047831 | 11415.805690 |
data = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_oceania.csv', index_col = 'country')
data
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 | ||||||||||||
Australia | 10039.59564 | 10949.64959 | 12217.22686 | 14526.12465 | 16788.62948 | 18334.19751 | 19477.00928 | 21888.88903 | 23424.76683 | 26997.93657 | 30687.75473 | 34435.36744 |
New Zealand | 10556.57566 | 12247.39532 | 13175.67800 | 14463.91893 | 16046.03728 | 16233.71770 | 17632.41040 | 19007.19129 | 18363.32494 | 21050.41377 | 23189.80135 | 25185.00911 |
years = data.columns.str.strip('gdpPercap_')
data.columns = years.astype(int)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-121-6dc9914b0f83> in <module> ----> 1 years = data.columns.str.strip('gdpPercap_') 2 data.columns = years.astype(int) 3 data.loc['Australia'].plot() ~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/accessor.py in __get__(self, obj, cls) 178 # we're accessing the attribute of the class, i.e., Dataset.geo 179 return self._accessor --> 180 accessor_obj = self._accessor(obj) 181 # Replace the property with the accessor object. Inspired by: 182 # https://www.pydanny.com/cached-property.html ~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/strings/accessor.py in __init__(self, data) 152 from pandas.core.arrays.string_ import StringDtype 153 --> 154 self._inferred_dtype = self._validate(data) 155 self._is_categorical = is_categorical_dtype(data.dtype) 156 self._is_string = isinstance(data.dtype, StringDtype) ~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/strings/accessor.py in _validate(data) 215 216 if inferred_dtype not in allowed_types: --> 217 raise AttributeError("Can only use .str accessor with string values!") 218 return inferred_dtype 219 AttributeError: Can only use .str accessor with string values!
data
1952 | 1957 | 1962 | 1967 | 1972 | 1977 | 1982 | 1987 | 1992 | 1997 | 2002 | 2007 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
country | ||||||||||||
Australia | 10039.59564 | 10949.64959 | 12217.22686 | 14526.12465 | 16788.62948 | 18334.19751 | 19477.00928 | 21888.88903 | 23424.76683 | 26997.93657 | 30687.75473 | 34435.36744 |
New Zealand | 10556.57566 | 12247.39532 | 13175.67800 | 14463.91893 | 16046.03728 | 16233.71770 | 17632.41040 | 19007.19129 | 18363.32494 | 21050.41377 | 23189.80135 | 25185.00911 |
data.loc['Australia'].plot()
<AxesSubplot:>
UsageError: Line magic function `%matplot` not found.
%matplotlib inline
data.T.plot()
plt.ylabel('GDP')
Text(0, 0.5, 'GDP')
plt.style.use('ggplot')
data.T.plot(kind='bar')
plt.ylabel('GDP')
Text(0, 0.5, 'GDP')
year= data.columns
gpd_aus = data.loc['Australia']
gpd_nz = data.loc['New Zealand']
plt.plot(year, gpd_aus, 'g:', label = 'Australia')
plt.plot(year, gpd_nz, 'r:', label = 'New Zealand')
plt.legend(loc = 'lower right')
plt.savefig('aus_nz_gdp.jpg')
plt.ylabel('GDP')
plt.xlabel('Years')
plt.title('Oceania')
plt.yscale('log')
plt.scatter(gpd_aus, gpd_nz)
<matplotlib.collections.PathCollection at 0x125c3f3a0>
data.T.plot.scatter(x='Australia', y='New Zealand')
<AxesSubplot:xlabel='Australia', ylabel='New Zealand'>
data_europe = pd.read_csv('/Users/suarezc/Desktop/Bootcamp_2021/Python/gapminder_data/data/gapminder_gdp_europe.csv', index_col = 'country')
data_europe.min().plot(label = 'min')
data_europe.max().plot(label='max')
plt.legend(loc = 'best')
plt.xticks(rotation = 90)
(array([-2., 0., 2., 4., 6., 8., 10., 12.]), [Text(-2.0, 0, 'gdpPercap_2002'), Text(0.0, 0, 'gdpPercap_1952'), Text(2.0, 0, 'gdpPercap_1962'), Text(4.0, 0, 'gdpPercap_1972'), Text(6.0, 0, 'gdpPercap_1982'), Text(8.0, 0, 'gdpPercap_1992'), Text(10.0, 0, 'gdpPercap_2002'), Text(12.0, 0, '')])
%matplotlib inline
import astropy.units as u
meter = 5 * u.km
seconds = 10 * u.second
m_sec = meter/seconds
m_sec
meter.to(u.cm)