In [1]:
import pandas as pd
import folium
In [3]:
data = pd.read_excel('./Datasets/gdp.xls')
data.head(50)
Out[3]:
Unnamed: 0 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4 Unnamed: 5 Unnamed: 6 Unnamed: 7 Unnamed: 8 Unnamed: 9 ... Unnamed: 52 Unnamed: 53 Unnamed: 54 Unnamed: 55 Unnamed: 56 Unnamed: 57 Unnamed: 58 Unnamed: 59 Unnamed: 60 Unnamed: 61
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 Country Name Country Code Indicator Name Indicator Code 1.960000e+03 1.961000e+03 1.962000e+03 1.963000e+03 1.964000e+03 1.965000e+03 ... 2.008000e+03 2.009000e+03 2.010000e+03 2.011000e+03 2.012000e+03 2.013000e+03 2.014000e+03 2.015000e+03 2.016000e+03 2017.0
2 Aruba ABW GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 2.791961e+09 2.498933e+09 2.467704e+09 2.584464e+09 NaN NaN NaN NaN NaN NaN
3 Afghanistan AFG GDP (current US$) NY.GDP.MKTP.CD 5.377778e+08 5.488889e+08 5.466667e+08 7.511112e+08 8.000000e+08 1.006667e+09 ... 1.019053e+10 1.248694e+10 1.593680e+10 1.793024e+10 2.053654e+10 2.026425e+10 2.061610e+10 1.921556e+10 1.946902e+10 NaN
4 Angola AGO GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 8.417803e+10 7.549238e+10 8.247091e+10 1.041159e+11 1.153984e+11 1.249121e+11 1.267769e+11 1.029622e+11 9.533511e+10 NaN
5 Albania ALB GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.288135e+10 1.204421e+10 1.192695e+10 1.289087e+10 1.231978e+10 1.277628e+10 1.322824e+10 1.133526e+10 1.186387e+10 NaN
6 Andorra AND GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 4.007353e+09 3.660531e+09 3.355695e+09 3.442063e+09 3.164615e+09 3.281585e+09 3.350736e+09 2.811489e+09 2.858518e+09 NaN
7 Arab World ARB GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 2.078209e+12 1.795805e+12 2.109668e+12 2.501554e+12 2.741239e+12 2.839627e+12 2.906616e+12 2.563302e+12 2.504703e+12 NaN
8 United Arab Emirates ARE GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 3.154746e+11 2.535474e+11 2.898804e+11 3.509084e+11 3.748180e+11 3.904273e+11 4.031977e+11 3.579492e+11 3.487433e+11 NaN
9 Argentina ARG GDP (current US$) NY.GDP.MKTP.CD NaN NaN 2.445060e+10 1.827212e+10 2.560525e+10 2.834471e+10 ... 3.615580e+11 3.329765e+11 4.236274e+11 5.301633e+11 5.459824e+11 5.520251e+11 5.263197e+11 5.847115e+11 5.454761e+11 NaN
10 Armenia ARM GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.166204e+10 8.647937e+09 9.260285e+09 1.014211e+10 1.061932e+10 1.112147e+10 1.160951e+10 1.055334e+10 1.057230e+10 NaN
11 American Samoa ASM GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 5.630000e+08 6.780000e+08 5.760000e+08 5.740000e+08 6.440000e+08 6.410000e+08 6.430000e+08 6.590000e+08 6.580000e+08 NaN
12 Antigua and Barbuda ATG GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.368431e+09 1.224253e+09 1.152469e+09 1.142043e+09 1.211412e+09 1.192925e+09 1.280133e+09 1.364863e+09 1.460145e+09 NaN
13 Australia AUS GDP (current US$) NY.GDP.MKTP.CD 1.859335e+10 1.966626e+10 1.991152e+10 2.152761e+10 2.378766e+10 2.596259e+10 ... 1.055335e+12 9.271683e+11 1.142877e+12 1.390557e+12 1.538194e+12 1.567179e+12 1.459598e+12 1.345383e+12 1.204616e+12 NaN
14 Austria AUT GDP (current US$) NY.GDP.MKTP.CD 6.592694e+09 7.311750e+09 7.756110e+09 8.374175e+09 9.169984e+09 9.994071e+09 ... 4.302943e+11 4.001723e+11 3.918927e+11 4.311203e+11 4.094252e+11 4.300687e+11 4.418854e+11 3.820659e+11 3.908000e+11 NaN
15 Azerbaijan AZE GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 4.885248e+10 4.429149e+10 5.290270e+10 6.595163e+10 6.968432e+10 7.416444e+10 7.524417e+10 5.307437e+10 3.784772e+10 NaN
16 Burundi BDI GDP (current US$) NY.GDP.MKTP.CD 1.960000e+08 2.030000e+08 2.135000e+08 2.327500e+08 2.607500e+08 1.589950e+08 ... 1.611634e+09 1.739781e+09 2.026864e+09 2.355652e+09 2.472385e+09 2.714506e+09 3.093647e+09 3.066681e+09 3.007029e+09 NaN
17 Belgium BEL GDP (current US$) NY.GDP.MKTP.CD 1.165872e+10 1.240015e+10 1.326402e+10 1.426002e+10 1.596011e+10 1.737146e+10 ... 5.186259e+11 4.845528e+11 4.835480e+11 5.270085e+11 4.978842e+11 5.209255e+11 5.310759e+11 4.552000e+11 4.679557e+11 NaN
18 Benin BEN GDP (current US$) NY.GDP.MKTP.CD 2.261956e+08 2.356682e+08 2.364349e+08 2.539276e+08 2.698190e+08 2.899087e+08 ... 7.132787e+09 7.097199e+09 6.970241e+09 7.814081e+09 8.152554e+09 9.156748e+09 9.707432e+09 8.290987e+09 8.583031e+09 NaN
19 Burkina Faso BFA GDP (current US$) NY.GDP.MKTP.CD 3.304428e+08 3.502472e+08 3.795672e+08 3.940407e+08 4.103218e+08 4.229168e+08 ... 8.369637e+09 8.369175e+09 8.979967e+09 1.072406e+10 1.116606e+10 1.194718e+10 1.237739e+10 1.041930e+10 1.169324e+10 NaN
20 Bangladesh BGD GDP (current US$) NY.GDP.MKTP.CD 4.274894e+09 4.817580e+09 5.081413e+09 5.319458e+09 5.386055e+09 5.906637e+09 ... 9.163128e+10 1.024778e+11 1.152791e+11 1.286379e+11 1.333557e+11 1.499905e+11 1.728855e+11 1.950787e+11 2.214152e+11 NaN
21 Bulgaria BGR GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 5.440914e+10 5.188448e+10 5.061003e+10 5.741839e+10 5.390303e+10 5.575874e+10 5.673201e+10 5.019912e+10 5.323788e+10 NaN
22 Bahrain BHR GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 2.571088e+10 2.293822e+10 2.571327e+10 2.877660e+10 3.074931e+10 3.253955e+10 3.338771e+10 3.112585e+10 3.217907e+10 NaN
23 Bahamas, The BHS GDP (current US$) NY.GDP.MKTP.CD 1.698039e+08 1.900980e+08 2.122549e+08 2.377451e+08 2.666667e+08 3.003922e+08 ... 8.247000e+09 7.820000e+09 7.910000e+09 7.890000e+09 1.072050e+10 1.067720e+10 1.084380e+10 1.124000e+10 1.126180e+10 NaN
24 Bosnia and Herzegovina BIH GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.911274e+10 1.761384e+10 1.717678e+10 1.864472e+10 1.722685e+10 1.817850e+10 1.855834e+10 1.620970e+10 1.691028e+10 NaN
25 Belarus BLR GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 6.076348e+10 4.920952e+10 5.722249e+10 6.175779e+10 6.568510e+10 7.552798e+10 7.881384e+10 5.645473e+10 4.740722e+10 NaN
26 Belize BLZ GDP (current US$) NY.GDP.MKTP.CD 2.807189e+07 2.996437e+07 3.185692e+07 3.374941e+07 3.619383e+07 4.006993e+07 ... 1.368625e+09 1.336957e+09 1.397113e+09 1.486712e+09 1.573619e+09 1.613706e+09 1.706498e+09 1.742546e+09 1.741100e+09 NaN
27 Bermuda BMU GDP (current US$) NY.GDP.MKTP.CD 8.446665e+07 8.924999e+07 9.414999e+07 9.636665e+07 1.075667e+08 1.143390e+08 ... 6.109928e+09 5.806378e+09 5.744414e+09 5.550771e+09 5.537537e+09 5.573710e+09 NaN NaN NaN NaN
28 Bolivia BOL GDP (current US$) NY.GDP.MKTP.CD 5.631101e+08 6.125189e+08 6.697225e+08 7.211430e+08 8.125431e+08 9.088745e+08 ... 1.667432e+10 1.733999e+10 1.964963e+10 2.396303e+10 2.708450e+10 3.065934e+10 3.299619e+10 3.300020e+10 3.380640e+10 NaN
29 Brazil BRA GDP (current US$) NY.GDP.MKTP.CD 1.516557e+10 1.523685e+10 1.992629e+10 2.302148e+10 2.121189e+10 2.179004e+10 ... 1.695825e+12 1.667020e+12 2.208872e+12 2.616202e+12 2.465189e+12 2.472807e+12 2.455993e+12 1.803653e+12 1.796187e+12 NaN
30 Barbados BRB GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 4.607300e+09 4.434050e+09 4.461650e+09 4.660900e+09 4.656350e+09 4.612500e+09 4.608350e+09 4.584150e+09 4.529050e+09 NaN
31 Brunei Darussalam BRN GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN 1.140402e+08 ... 1.439310e+10 1.073237e+10 1.370737e+10 1.852532e+10 1.904850e+10 1.809383e+10 1.709834e+10 1.293039e+10 1.140065e+10 NaN
32 Bhutan BTN GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.258332e+09 1.264758e+09 1.585473e+09 1.820208e+09 1.823692e+09 1.798334e+09 1.944783e+09 2.059259e+09 2.212639e+09 NaN
33 Botswana BWA GDP (current US$) NY.GDP.MKTP.CD 3.041231e+07 3.290234e+07 3.564321e+07 3.809115e+07 4.161397e+07 4.579087e+07 ... 1.094507e+10 1.026713e+10 1.278665e+10 1.568293e+10 1.468628e+10 1.491578e+10 1.625945e+10 1.443057e+10 1.558114e+10 NaN
34 Central African Republic CAF GDP (current US$) NY.GDP.MKTP.CD 1.121556e+08 1.231346e+08 1.244827e+08 1.293791e+08 1.420251e+08 1.505748e+08 ... 1.985239e+09 1.981728e+09 1.986015e+09 2.212700e+09 2.184184e+09 1.518565e+09 1.702899e+09 1.583777e+09 1.756125e+09 NaN
35 Canada CAN GDP (current US$) NY.GDP.MKTP.CD 4.109345e+10 4.076797e+10 4.197885e+10 4.465717e+10 4.888294e+10 5.390957e+10 ... 1.549131e+12 1.371153e+12 1.613464e+12 1.788648e+12 1.824289e+12 1.842628e+12 1.799269e+12 1.559623e+12 1.535768e+12 NaN
36 Central Europe and the Baltics CEB GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.524160e+12 1.281584e+12 1.313815e+12 1.446816e+12 1.351349e+12 1.422301e+12 1.463247e+12 1.285643e+12 1.312192e+12 NaN
37 Switzerland CHE GDP (current US$) NY.GDP.MKTP.CD 9.522747e+09 1.071271e+10 1.187998e+10 1.306364e+10 1.448056e+10 1.534674e+10 ... 5.543635e+11 5.415065e+11 5.837830e+11 6.995796e+11 6.680436e+11 6.885042e+11 7.091826e+11 6.792892e+11 6.688513e+11 NaN
38 Channel Islands CHI GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
39 Chile CHL GDP (current US$) NY.GDP.MKTP.CD 4.110000e+09 4.609727e+09 5.416273e+09 5.668188e+09 5.982348e+09 6.026594e+09 ... 1.796385e+11 1.723895e+11 2.185376e+11 2.522520e+11 2.671223e+11 2.783843e+11 2.609903e+11 2.425179e+11 2.470279e+11 NaN
40 China CHN GDP (current US$) NY.GDP.MKTP.CD 5.971647e+10 5.005687e+10 4.720936e+10 5.070680e+10 5.970834e+10 7.043627e+10 ... 4.598206e+12 5.109954e+12 6.100620e+12 7.572554e+12 8.560547e+12 9.607224e+12 1.048237e+13 1.106467e+13 1.119915e+13 NaN
41 Cote d'Ivoire CIV GDP (current US$) NY.GDP.MKTP.CD 5.462036e+08 6.182456e+08 6.452843e+08 7.610470e+08 9.210633e+08 9.197714e+08 ... 2.422490e+10 2.427749e+10 2.488451e+10 2.538162e+10 2.704056e+10 3.127305e+10 3.537260e+10 3.314510e+10 3.637261e+10 NaN
42 Cameroon CMR GDP (current US$) NY.GDP.MKTP.CD 6.187410e+08 6.575974e+08 6.993737e+08 7.236244e+08 7.823845e+08 8.141399e+08 ... 2.640978e+10 2.601793e+10 2.614382e+10 2.933701e+10 2.910444e+10 3.234815e+10 3.494295e+10 3.091622e+10 3.221750e+10 NaN
43 Congo, Dem. Rep. COD GDP (current US$) NY.GDP.MKTP.CD 3.359404e+09 3.086747e+09 3.779841e+09 6.213186e+09 2.881545e+09 4.043902e+09 ... 1.920606e+10 1.826277e+10 2.052329e+10 2.384901e+10 2.746322e+10 3.267168e+10 3.591765e+10 3.791770e+10 3.538178e+10 NaN
44 Congo, Rep. COG GDP (current US$) NY.GDP.MKTP.CD 1.317319e+08 1.516757e+08 1.665212e+08 1.722334e+08 1.856937e+08 1.983181e+08 ... 1.185901e+10 9.593538e+09 1.200788e+10 1.442561e+10 1.367793e+10 1.408585e+10 1.417744e+10 8.553155e+09 7.833509e+09 NaN
45 Colombia COL GDP (current US$) NY.GDP.MKTP.CD 4.040948e+09 4.552914e+09 4.968604e+09 4.838841e+09 5.992169e+09 5.790248e+09 ... 2.439824e+11 2.338217e+11 2.870182e+11 3.354152e+11 3.696597e+11 3.801919e+11 3.781957e+11 2.915196e+11 2.824626e+11 NaN
46 Comoros COM GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 5.231349e+08 5.241573e+08 5.304934e+08 5.862818e+08 5.708659e+08 6.186639e+08 6.477207e+08 5.656898e+08 6.166545e+08 NaN
47 Cabo Verde CPV GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.789334e+09 1.711817e+09 1.664311e+09 1.864824e+09 1.751889e+09 1.850951e+09 1.858122e+09 1.574289e+09 1.617467e+09 NaN
48 Costa Rica CRI GDP (current US$) NY.GDP.MKTP.CD 5.075138e+08 4.903252e+08 4.791808e+08 5.119021e+08 5.425784e+08 5.929812e+08 ... 3.061293e+10 3.056236e+10 3.726864e+10 4.226270e+10 4.647313e+10 4.974509e+10 5.065600e+10 5.484010e+10 5.743551e+10 NaN
49 Caribbean small states CSS GDP (current US$) NY.GDP.MKTP.CD 2.004785e+09 2.169733e+09 2.289495e+09 2.431592e+09 2.626896e+09 2.828615e+09 ... 6.659654e+10 5.588748e+10 6.094550e+10 6.619759e+10 7.064785e+10 7.128481e+10 7.139278e+10 6.951622e+10 6.670736e+10 NaN

50 rows × 62 columns

In [4]:
data = data.drop(0)
data.head()
Out[4]:
Unnamed: 0 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4 Unnamed: 5 Unnamed: 6 Unnamed: 7 Unnamed: 8 Unnamed: 9 ... Unnamed: 52 Unnamed: 53 Unnamed: 54 Unnamed: 55 Unnamed: 56 Unnamed: 57 Unnamed: 58 Unnamed: 59 Unnamed: 60 Unnamed: 61
1 Country Name Country Code Indicator Name Indicator Code 1.960000e+03 1.961000e+03 1.962000e+03 1.963000e+03 1.964000e+03 1.965000e+03 ... 2.008000e+03 2.009000e+03 2.010000e+03 2.011000e+03 2.012000e+03 2.013000e+03 2.014000e+03 2.015000e+03 2.016000e+03 2017.0
2 Aruba ABW GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 2.791961e+09 2.498933e+09 2.467704e+09 2.584464e+09 NaN NaN NaN NaN NaN NaN
3 Afghanistan AFG GDP (current US$) NY.GDP.MKTP.CD 5.377778e+08 5.488889e+08 5.466667e+08 7.511112e+08 8.000000e+08 1.006667e+09 ... 1.019053e+10 1.248694e+10 1.593680e+10 1.793024e+10 2.053654e+10 2.026425e+10 2.061610e+10 1.921556e+10 1.946902e+10 NaN
4 Angola AGO GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 8.417803e+10 7.549238e+10 8.247091e+10 1.041159e+11 1.153984e+11 1.249121e+11 1.267769e+11 1.029622e+11 9.533511e+10 NaN
5 Albania ALB GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.288135e+10 1.204421e+10 1.192695e+10 1.289087e+10 1.231978e+10 1.277628e+10 1.322824e+10 1.133526e+10 1.186387e+10 NaN

5 rows × 62 columns

In [5]:
data.columns = data.iloc[0]
In [6]:
data.head()
Out[6]:
1 Country Name Country Code Indicator Name Indicator Code 1960.0 1961.0 1962.0 1963.0 1964.0 1965.0 ... 2008.0 2009.0 2010.0 2011.0 2012.0 2013.0 2014.0 2015.0 2016.0 2017.0
1 Country Name Country Code Indicator Name Indicator Code 1.960000e+03 1.961000e+03 1.962000e+03 1.963000e+03 1.964000e+03 1.965000e+03 ... 2.008000e+03 2.009000e+03 2.010000e+03 2.011000e+03 2.012000e+03 2.013000e+03 2.014000e+03 2.015000e+03 2.016000e+03 2017.0
2 Aruba ABW GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 2.791961e+09 2.498933e+09 2.467704e+09 2.584464e+09 NaN NaN NaN NaN NaN NaN
3 Afghanistan AFG GDP (current US$) NY.GDP.MKTP.CD 5.377778e+08 5.488889e+08 5.466667e+08 7.511112e+08 8.000000e+08 1.006667e+09 ... 1.019053e+10 1.248694e+10 1.593680e+10 1.793024e+10 2.053654e+10 2.026425e+10 2.061610e+10 1.921556e+10 1.946902e+10 NaN
4 Angola AGO GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 8.417803e+10 7.549238e+10 8.247091e+10 1.041159e+11 1.153984e+11 1.249121e+11 1.267769e+11 1.029622e+11 9.533511e+10 NaN
5 Albania ALB GDP (current US$) NY.GDP.MKTP.CD NaN NaN NaN NaN NaN NaN ... 1.288135e+10 1.204421e+10 1.192695e+10 1.289087e+10 1.231978e+10 1.277628e+10 1.322824e+10 1.133526e+10 1.186387e+10 NaN

5 rows × 62 columns

In [7]:
del data[2017]
In [8]:
#data = data.drop(0)
needed = data[['Country Code', 2016]].copy()
In [9]:
needed.head()
Out[9]:
1 Country Code 2016.0
1 Country Code 2.016000e+03
2 ABW NaN
3 AFG 1.946902e+10
4 AGO 9.533511e+10
5 ALB 1.186387e+10
In [10]:
print(needed[needed['Country Code'].str.contains('LTU')])
1   Country Code        2016.0
143          LTU  4.277303e+10
In [11]:
needed = needed.dropna()
needed['data'] = (needed[2016] > 91000000000) * 1
needed.head()
better = needed[needed['data'] == 0]
print(better)
1    Country Code        2016.0  data
1    Country Code  2.016000e+03     0
3             AFG  1.946902e+10     0
5             ALB  1.186387e+10     0
6             AND  2.858518e+09     0
10            ARM  1.057230e+10     0
11            ASM  6.580000e+08     0
12            ATG  1.460145e+09     0
15            AZE  3.784772e+10     0
16            BDI  3.007029e+09     0
18            BEN  8.583031e+09     0
19            BFA  1.169324e+10     0
21            BGR  5.323788e+10     0
22            BHR  3.217907e+10     0
23            BHS  1.126180e+10     0
24            BIH  1.691028e+10     0
25            BLR  4.740722e+10     0
26            BLZ  1.741100e+09     0
28            BOL  3.380640e+10     0
30            BRB  4.529050e+09     0
31            BRN  1.140065e+10     0
32            BTN  2.212639e+09     0
33            BWA  1.558114e+10     0
34            CAF  1.756125e+09     0
41            CIV  3.637261e+10     0
42            CMR  3.221750e+10     0
43            COD  3.538178e+10     0
44            COG  7.833509e+09     0
46            COM  6.166545e+08     0
47            CPV  1.617467e+09     0
48            CRI  5.743551e+10     0
..            ...           ...   ...
211           SLV  2.679747e+10     0
212           SMR  1.590708e+09     0
213           SOM  6.217000e+09     0
214           SRB  3.829985e+10     0
219           STP  3.427817e+08     0
220           SUR  3.278425e+09     0
221           SVK  8.976860e+10     0
222           SVN  4.470860e+10     0
224           SWZ  3.720649e+09     0
226           SYC  1.427324e+09     0
229           TCD  9.600761e+09     0
232           TGO  4.399996e+09     0
234           TJK  6.951657e+09     0
235           TKM  3.617989e+10     0
237           TLS  1.782974e+09     0
239           TON  4.015620e+08     0
242           TTO  2.189471e+10     0
243           TUN  4.206255e+10     0
245           TUV  3.421888e+07     0
246           TZA  4.734007e+10     0
247           UGA  2.407893e+10     0
250           URY  5.241972e+10     0
252           UZB  6.722034e+10     0
253           VCT  7.682242e+08     0
258           VUT  7.735029e+08     0
260           WSM  7.863563e+08     0
261           XKX  6.649889e+09     0
262           YEM  2.731761e+10     0
264           ZMB  2.106399e+10     0
265           ZWE  1.661996e+10     0

[131 rows x 3 columns]
In [12]:
world_geo = r'./Data Science Course/world.json'
maps = folium.Map(location=[0, 0], zoom_start=1.5)
maps.choropleth(geo_data=world_geo, data=needed, columns=['Country Code', 'data'], 
                key_on="feature.id", fill_color='Reds', line_opacity=0.2, 
                fill_opacity=0.7, legend_name="Countries with higher GDP than net worth Bill Gates")
In [13]:
maps
Out[13]:
In [14]:
maps.save('BillGates.html')
In [40]:
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
In [7]:
aproval = pd.read_csv('./Datasets/approval_polllist.csv')
aproval.head()
Out[7]:
president subgroup modeldate startdate enddate pollster grade samplesize population weight ... disapprove adjusted_approve adjusted_disapprove multiversions tracking url poll_id question_id createddate timestamp
0 Donald Trump All polls 5/12/2018 1/20/2017 1/22/2017 Morning Consult NaN 1992 rv 0.798422 ... 37.0 42.38768 39.78366 NaN NaN http://www.politico.com/story/2017/01/poll-vot... 49249 77261 1/23/2017 00:07:30 12 May 2018
1 Donald Trump All polls 5/12/2018 1/20/2017 1/22/2017 Gallup B- 1500 a 0.229544 ... 45.0 46.21323 43.06819 NaN T http://www.gallup.com/poll/201617/gallup-daily... 49253 77265 1/23/2017 00:07:30 12 May 2018
2 Donald Trump All polls 5/12/2018 1/20/2017 1/24/2017 Ipsos A- 1632 a 0.287416 ... 45.2 42.34766 44.01295 NaN T http://polling.reuters.com/#poll/CP3_2/ 49426 77599 3/1/2017 00:07:30 12 May 2018
3 Donald Trump All polls 5/12/2018 1/21/2017 1/23/2017 Gallup B- 1500 a 0.211740 ... 46.0 46.21323 44.06819 NaN T http://www.gallup.com/poll/201617/gallup-daily... 49262 77274 1/24/2017 00:07:30 12 May 2018
4 Donald Trump All polls 5/12/2018 1/22/2017 1/24/2017 Rasmussen Reports/Pulse Opinion Research C+ 1500 lv 0.205238 ... 43.0 51.81438 43.38675 NaN T http://www.rasmussenreports.com/public_content... 49266 77278 1/25/2017 00:07:30 12 May 2018

5 rows × 22 columns

In [8]:
filter = aproval['president'].str.contains('Donald Trump')
aproval = aproval[filter]
In [9]:
aproval.tail()
Out[9]:
president subgroup modeldate startdate enddate pollster grade samplesize population weight ... disapprove adjusted_approve adjusted_disapprove multiversions tracking url poll_id question_id createddate timestamp
4055 Donald Trump Voters 5/12/2018 5/5/2018 5/9/2018 Ipsos A- 1230 rv 0.219110 ... 53.0 45.01081 51.46164 NaN T http://polling.reuters.com/#poll/CP3_2/filters... 52392 82724 5/12/2018 00:07:55 12 May 2018
4056 Donald Trump Voters 5/12/2018 5/6/2018 5/8/2018 YouGov B 1232 rv 1.042316 ... 52.0 43.27277 52.55732 NaN NaN https://d25d2506sfb94s.cloudfront.net/cumulus_... 52360 82669 5/9/2018 00:07:55 12 May 2018
4057 Donald Trump Voters 5/12/2018 5/6/2018 5/10/2018 Ipsos A- 1317 rv 1.208914 ... 51.8 45.51081 50.26164 NaN T http://polling.reuters.com/#poll/CP3_2/filters... 52391 82723 5/12/2018 00:07:55 12 May 2018
4058 Donald Trump Voters 5/12/2018 5/7/2018 5/9/2018 Rasmussen Reports/Pulse Opinion Research C+ 1500 lv 0.156442 ... 50.0 44.09094 49.80976 NaN T http://www.rasmussenreports.com/public_content... 52365 82688 5/10/2018 00:07:55 12 May 2018
4059 Donald Trump Voters 5/12/2018 5/8/2018 5/10/2018 Rasmussen Reports/Pulse Opinion Research C+ 1500 lv 0.494751 ... 49.0 45.09094 48.80976 NaN T http://www.rasmussenreports.com/public_content... 52387 82718 5/11/2018 00:07:55 12 May 2018

5 rows × 22 columns

In [14]:
aproval['startdate'].describe()
aproval = aproval[['startdate','disapprove','approve']]
aproval = aproval.dropna()
In [41]:
x = aproval[['startdate', 'disapprove']]
[datetime.strptime(value, '%m/%d/%y') for value in aproval['startdate'] ]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-41-5900c15a7309> in <module>()
      1 x = aproval[['startdate', 'disapprove']]
----> 2 [datetime.strptime(value, '%m/%d/%y') for value in aproval['startdate'] ]

<ipython-input-41-5900c15a7309> in <listcomp>(.0)
      1 x = aproval[['startdate', 'disapprove']]
----> 2 [datetime.strptime(value, '%m/%d/%y') for value in aproval['startdate'] ]

TypeError: strptime() argument 1 must be str, not int
In [38]:
 
Out[38]:
startdate      object
disapprove    float64
dtype: object
In [39]:
sns.lmplot(data=x, x='startdate', y='disapprove')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-39-27a10a5013dd> in <module>()
----> 1 sns.lmplot(data=x, x='startdate', y='disapprove')

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in lmplot(x, y, data, hue, col, row, palette, col_wrap, size, aspect, markers, sharex, sharey, hue_order, col_order, row_order, legend, legend_out, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, x_jitter, y_jitter, scatter_kws, line_kws)
    588         scatter_kws=scatter_kws, line_kws=line_kws,
    589         )
--> 590     facets.map_dataframe(regplot, x, y, **regplot_kws)
    591 
    592     # Add a legend

~/anaconda3/lib/python3.6/site-packages/seaborn/axisgrid.py in map_dataframe(self, func, *args, **kwargs)
    807 
    808             # Draw the plot
--> 809             self._facet_plot(func, ax, args, kwargs)
    810 
    811         # Finalize the annotations and layout

~/anaconda3/lib/python3.6/site-packages/seaborn/axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)
    825 
    826         # Draw the plot
--> 827         func(*plot_args, **plot_kwargs)
    828 
    829         # Sort out the supporting information

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in regplot(x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, label, color, marker, scatter_kws, line_kws, ax)
    788     scatter_kws["marker"] = marker
    789     line_kws = {} if line_kws is None else copy.copy(line_kws)
--> 790     plotter.plot(ax, scatter_kws, line_kws)
    791     return ax
    792 

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in plot(self, ax, scatter_kws, line_kws)
    340             self.scatterplot(ax, scatter_kws)
    341         if self.fit_reg:
--> 342             self.lineplot(ax, line_kws)
    343 
    344         # Label the axes

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in lineplot(self, ax, kws)
    385 
    386         # Fit the regression model
--> 387         grid, yhat, err_bands = self.fit_regression(ax)
    388 
    389         # Get set default aesthetics

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in fit_regression(self, ax, x_range, grid)
    208             yhat, yhat_boots = self.fit_logx(grid)
    209         else:
--> 210             yhat, yhat_boots = self.fit_fast(grid)
    211 
    212         # Compute the confidence interval at each grid point

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in fit_fast(self, grid)
    223         grid = np.c_[np.ones(len(grid)), grid]
    224         reg_func = lambda _x, _y: np.linalg.pinv(_x).dot(_y)
--> 225         yhat = grid.dot(reg_func(X, y))
    226         if self.ci is None:
    227             return yhat, None

~/anaconda3/lib/python3.6/site-packages/seaborn/regression.py in <lambda>(_x, _y)
    222         X, y = np.c_[np.ones(len(self.x)), self.x], self.y
    223         grid = np.c_[np.ones(len(grid)), grid]
--> 224         reg_func = lambda _x, _y: np.linalg.pinv(_x).dot(_y)
    225         yhat = grid.dot(reg_func(X, y))
    226         if self.ci is None:

~/anaconda3/lib/python3.6/site-packages/numpy/linalg/linalg.py in pinv(a, rcond)
   1721         res = empty(a.shape[:-2] + (a.shape[-1], a.shape[-2]), dtype=a.dtype)
   1722         return wrap(res)
-> 1723     a = a.conjugate()
   1724     u, s, vt = svd(a, full_matrices=False)
   1725 

AttributeError: 'str' object has no attribute 'conjugate'
In [6]:
ufo = pd.read_csv('./Datasets/complete.csv', error_bad_lines=False)
ufo.head()
b'Skipping line 878: expected 11 fields, saw 12\nSkipping line 1713: expected 11 fields, saw 12\nSkipping line 1815: expected 11 fields, saw 12\nSkipping line 2858: expected 11 fields, saw 12\nSkipping line 3734: expected 11 fields, saw 12\nSkipping line 4756: expected 11 fields, saw 12\nSkipping line 5389: expected 11 fields, saw 12\nSkipping line 5423: expected 11 fields, saw 12\nSkipping line 5614: expected 11 fields, saw 12\nSkipping line 5849: expected 11 fields, saw 12\nSkipping line 6093: expected 11 fields, saw 12\nSkipping line 7516: expected 11 fields, saw 12\nSkipping line 7626: expected 11 fields, saw 12\nSkipping line 8893: expected 11 fields, saw 12\nSkipping line 9015: expected 11 fields, saw 12\nSkipping line 9571: expected 11 fields, saw 12\nSkipping line 9620: expected 11 fields, saw 12\nSkipping line 9751: expected 11 fields, saw 12\nSkipping line 10157: expected 11 fields, saw 12\nSkipping line 10427: expected 11 fields, saw 12\nSkipping line 12035: expected 11 fields, saw 12\nSkipping line 12113: expected 11 fields, saw 12\nSkipping line 12144: expected 11 fields, saw 12\nSkipping line 12891: expected 11 fields, saw 12\nSkipping line 14613: expected 11 fields, saw 12\nSkipping line 16031: expected 11 fields, saw 12\nSkipping line 16344: expected 11 fields, saw 12\nSkipping line 16399: expected 11 fields, saw 12\nSkipping line 16635: expected 11 fields, saw 12\nSkipping line 16722: expected 11 fields, saw 12\nSkipping line 18241: expected 11 fields, saw 12\nSkipping line 18367: expected 11 fields, saw 12\nSkipping line 18479: expected 11 fields, saw 12\nSkipping line 19814: expected 11 fields, saw 12\nSkipping line 19859: expected 11 fields, saw 12\nSkipping line 19909: expected 11 fields, saw 12\nSkipping line 19935: expected 11 fields, saw 12\nSkipping line 20386: expected 11 fields, saw 12\nSkipping line 20533: expected 11 fields, saw 12\nSkipping line 20764: expected 11 fields, saw 12\nSkipping line 21145: expected 11 fields, saw 12\nSkipping line 21291: expected 11 fields, saw 12\nSkipping line 21309: expected 11 fields, saw 12\nSkipping line 21576: expected 11 fields, saw 12\nSkipping line 21966: expected 11 fields, saw 12\nSkipping line 22092: expected 11 fields, saw 12\nSkipping line 22108: expected 11 fields, saw 12\nSkipping line 22236: expected 11 fields, saw 12\nSkipping line 22785: expected 11 fields, saw 12\nSkipping line 23143: expected 11 fields, saw 12\nSkipping line 23145: expected 11 fields, saw 12\nSkipping line 23251: expected 11 fields, saw 12\nSkipping line 23369: expected 11 fields, saw 12\nSkipping line 23464: expected 11 fields, saw 12\nSkipping line 23622: expected 11 fields, saw 12\nSkipping line 23732: expected 11 fields, saw 12\nSkipping line 23924: expected 11 fields, saw 12\nSkipping line 24696: expected 11 fields, saw 12\nSkipping line 25543: expected 11 fields, saw 12\nSkipping line 25703: expected 11 fields, saw 12\nSkipping line 25815: expected 11 fields, saw 12\nSkipping line 26185: expected 11 fields, saw 12\nSkipping line 27424: expected 11 fields, saw 12\nSkipping line 27465: expected 11 fields, saw 12\nSkipping line 28083: expected 11 fields, saw 12\nSkipping line 28282: expected 11 fields, saw 12\nSkipping line 28460: expected 11 fields, saw 12\nSkipping line 28745: expected 11 fields, saw 12\nSkipping line 29674: expected 11 fields, saw 12\nSkipping line 30342: expected 11 fields, saw 12\nSkipping line 30417: expected 11 fields, saw 12\nSkipping line 31154: expected 11 fields, saw 12\nSkipping line 31308: expected 11 fields, saw 12\nSkipping line 32198: expected 11 fields, saw 12\nSkipping line 32439: expected 11 fields, saw 12\nSkipping line 32675: expected 11 fields, saw 12\nSkipping line 33134: expected 11 fields, saw 12\nSkipping line 33442: expected 11 fields, saw 12\nSkipping line 34184: expected 11 fields, saw 12\nSkipping line 34731: expected 11 fields, saw 12\nSkipping line 34869: expected 11 fields, saw 12\nSkipping line 35107: expected 11 fields, saw 12\nSkipping line 35300: expected 11 fields, saw 12\nSkipping line 35396: expected 11 fields, saw 12\nSkipping line 35913: expected 11 fields, saw 12\nSkipping line 36445: expected 11 fields, saw 12\nSkipping line 36693: expected 11 fields, saw 12\nSkipping line 36723: expected 11 fields, saw 12\nSkipping line 37293: expected 11 fields, saw 12\nSkipping line 37361: expected 11 fields, saw 12\nSkipping line 37980: expected 11 fields, saw 12\nSkipping line 38090: expected 11 fields, saw 12\nSkipping line 38197: expected 11 fields, saw 12\nSkipping line 39431: expected 11 fields, saw 12\nSkipping line 39598: expected 11 fields, saw 12\nSkipping line 39679: expected 11 fields, saw 12\nSkipping line 39794: expected 11 fields, saw 12\nSkipping line 40021: expected 11 fields, saw 12\nSkipping line 40430: expected 11 fields, saw 12\nSkipping line 42858: expected 11 fields, saw 12\nSkipping line 43662: expected 11 fields, saw 12\nSkipping line 44162: expected 11 fields, saw 12\nSkipping line 45529: expected 11 fields, saw 12\nSkipping line 46678: expected 11 fields, saw 12\nSkipping line 46788: expected 11 fields, saw 12\nSkipping line 46811: expected 11 fields, saw 12\nSkipping line 46924: expected 11 fields, saw 12\nSkipping line 47287: expected 11 fields, saw 12\nSkipping line 47377: expected 11 fields, saw 12\nSkipping line 47419: expected 11 fields, saw 12\nSkipping line 47492: expected 11 fields, saw 12\nSkipping line 47629: expected 11 fields, saw 12\nSkipping line 48125: expected 11 fields, saw 12\nSkipping line 48932: expected 11 fields, saw 12\nSkipping line 48971: expected 11 fields, saw 12\nSkipping line 49440: expected 11 fields, saw 12\nSkipping line 49457: expected 11 fields, saw 12\nSkipping line 50670: expected 11 fields, saw 12\nSkipping line 50960: expected 11 fields, saw 12\nSkipping line 51275: expected 11 fields, saw 12\nSkipping line 51649: expected 11 fields, saw 12\nSkipping line 51993: expected 11 fields, saw 12\nSkipping line 52023: expected 11 fields, saw 12\nSkipping line 52059: expected 11 fields, saw 12\nSkipping line 52259: expected 11 fields, saw 12\nSkipping line 52368: expected 11 fields, saw 12\nSkipping line 52783: expected 11 fields, saw 12\nSkipping line 53064: expected 11 fields, saw 12\nSkipping line 53135: expected 11 fields, saw 12\nSkipping line 53514: expected 11 fields, saw 12\nSkipping line 54092: expected 11 fields, saw 12\nSkipping line 55403: expected 11 fields, saw 12\nSkipping line 57476: expected 11 fields, saw 12\nSkipping line 58646: expected 11 fields, saw 12\nSkipping line 58808: expected 11 fields, saw 12\nSkipping line 59119: expected 11 fields, saw 12\nSkipping line 59727: expected 11 fields, saw 12\nSkipping line 60386: expected 11 fields, saw 12\nSkipping line 60478: expected 11 fields, saw 12\nSkipping line 60542: expected 11 fields, saw 12\nSkipping line 60913: expected 11 fields, saw 12\nSkipping line 61032: expected 11 fields, saw 12\nSkipping line 61640: expected 11 fields, saw 12\nSkipping line 61732: expected 11 fields, saw 12\nSkipping line 62029: expected 11 fields, saw 12\nSkipping line 62219: expected 11 fields, saw 12\nSkipping line 63657: expected 11 fields, saw 12\nSkipping line 64712: expected 11 fields, saw 12\n'
b'Skipping line 65881: expected 11 fields, saw 12\nSkipping line 66093: expected 11 fields, saw 12\nSkipping line 66095: expected 11 fields, saw 12\nSkipping line 66476: expected 11 fields, saw 12\nSkipping line 66549: expected 11 fields, saw 12\nSkipping line 66550: expected 11 fields, saw 12\nSkipping line 68102: expected 11 fields, saw 12\nSkipping line 69441: expected 11 fields, saw 12\nSkipping line 70104: expected 11 fields, saw 12\nSkipping line 70452: expected 11 fields, saw 12\nSkipping line 70642: expected 11 fields, saw 12\nSkipping line 70644: expected 11 fields, saw 12\nSkipping line 70716: expected 11 fields, saw 12\nSkipping line 71345: expected 11 fields, saw 12\nSkipping line 71634: expected 11 fields, saw 12\nSkipping line 72091: expected 11 fields, saw 12\nSkipping line 72119: expected 11 fields, saw 12\nSkipping line 73543: expected 11 fields, saw 12\nSkipping line 74654: expected 11 fields, saw 12\nSkipping line 74785: expected 11 fields, saw 12\nSkipping line 74918: expected 11 fields, saw 12\nSkipping line 75062: expected 11 fields, saw 12\nSkipping line 75346: expected 11 fields, saw 12\nSkipping line 75416: expected 11 fields, saw 12\nSkipping line 75677: expected 11 fields, saw 12\nSkipping line 75833: expected 11 fields, saw 12\nSkipping line 76117: expected 11 fields, saw 12\nSkipping line 76834: expected 11 fields, saw 12\nSkipping line 77540: expected 11 fields, saw 12\nSkipping line 77568: expected 11 fields, saw 12\nSkipping line 77607: expected 11 fields, saw 12\nSkipping line 77871: expected 11 fields, saw 12\nSkipping line 78117: expected 11 fields, saw 12\nSkipping line 78526: expected 11 fields, saw 12\nSkipping line 78605: expected 11 fields, saw 12\nSkipping line 79151: expected 11 fields, saw 12\nSkipping line 79945: expected 11 fields, saw 12\nSkipping line 80156: expected 11 fields, saw 12\nSkipping line 80328: expected 11 fields, saw 12\nSkipping line 80382: expected 11 fields, saw 12\nSkipping line 80421: expected 11 fields, saw 12\nSkipping line 80503: expected 11 fields, saw 12\nSkipping line 82071: expected 11 fields, saw 12\nSkipping line 82566: expected 11 fields, saw 12\nSkipping line 86123: expected 11 fields, saw 12\nSkipping line 87218: expected 11 fields, saw 12\nSkipping line 87457: expected 11 fields, saw 12\nSkipping line 87579: expected 11 fields, saw 12\n'
/Users/timangevare/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2728: DtypeWarning: Columns (5,9) have mixed types. Specify dtype option on import or set low_memory=False.
  interactivity=interactivity, compiler=compiler, result=result)
Out[6]:
datetime city state country shape duration (seconds) duration (hours/min) comments date posted latitude longitude
0 10/10/1949 20:30 san marcos tx us cylinder 2700 45 minutes This event took place in early fall around 194... 4/27/2004 29.8830556 -97.941111
1 10/10/1949 21:00 lackland afb tx NaN light 7200 1-2 hrs 1949 Lackland AFB&#44 TX. Lights racing acros... 12/16/2005 29.38421 -98.581082
2 10/10/1955 17:00 chester (uk/england) NaN gb circle 20 20 seconds Green/Orange circular disc over Chester&#44 En... 1/21/2008 53.2 -2.916667
3 10/10/1956 21:00 edna tx us circle 20 1/2 hour My older brother and twin sister were leaving ... 1/17/2004 28.9783333 -96.645833
4 10/10/1960 20:00 kaneohe hi us light 900 15 minutes AS a Marine 1st Lt. flying an FJ4B fighter/att... 1/22/2004 21.4180556 -157.803611
In [18]:
import matplotlib.pyplot as plt
import plotly.plotly as py
import pl
plotly.tools.set_credentials_file(username='dutchtim2003', api_key='Ex0nnGVfsqFoEnfZeqwR')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-18-503bde885681> in <module>()
      1 import matplotlib.pyplot as plt
      2 import plotly.plotly as py
----> 3 plotly.tools.set_credentials_file(username='dutchtim2003', api_key='Ex0nnGVfsqFoEnfZeqwR')

NameError: name 'plotly' is not defined
In [13]:
ufo['text'] = ufo['date posted'] + ' ' + ufo['duration (hours/min)'] + '\n' + ufo['comments']
In [15]:
data = [ dict(
        type = 'scattergeo',
        locationmode = 'USA-states',
        lon = ufo['longitude'],
        lat = ufo['latitude'],
        text = ufo['text'],
        mode = 'markers',
        marker = dict(
            size = 8,
            opacity = 0.8,
            reversescale = True,
            autocolorscale = False,
            symbol = 'square',
            line = dict(
                width=1,
                color='rgba(102, 102, 102)'
            ),
            cmin = 0,
            )
        )]
In [16]:
layout = dict(
        title = 'UFO sightings',
        colorbar = False,
        geo = dict(
            scope='usa',
            projection=dict( type='albers usa' ),
            showland = True,
            landcolor = "rgb(250, 250, 250)",
            subunitcolor = "rgb(217, 217, 217)",
            countrycolor = "rgb(217, 217, 217)",
            countrywidth = 0.5,
            subunitwidth = 0.5
        ),
    )
In [17]:
fig = dict( data=data, layout=layout )
py.iplot( fig, validate=False, filename='UFO' )
/Users/timangevare/anaconda3/lib/python3.6/site-packages/plotly/plotly/plotly.py:224: UserWarning:

Woah there! Look at all those points! Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts. Here are some suggestions:
(1) Use the `plotly.graph_objs.Scattergl` trace object to generate a WebGl graph.
(2) Trying using the image API to return an image instead of a graph URL
(3) Use matplotlib
(4) See if you can create your visualization with fewer data points

If the visualization you're using aggregates points (e.g., box plot, histogram, etc.) you can disregard this warning.

Aw, snap! We didn't get a username with your request.

Don't have an account? https://plot.ly/api_signup

Questions? accounts@plot.ly
---------------------------------------------------------------------------
PlotlyError                               Traceback (most recent call last)
<ipython-input-17-b11ad4e3a0e7> in <module>()
      1 fig = dict( data=data, layout=layout )
----> 2 py.iplot( fig, validate=False, filename='UFO' )

~/anaconda3/lib/python3.6/site-packages/plotly/plotly/plotly.py in iplot(figure_or_data, **plot_options)
    162         embed_options['height'] = str(embed_options['height']) + 'px'
    163 
--> 164     return tools.embed(url, **embed_options)
    165 
    166 

~/anaconda3/lib/python3.6/site-packages/plotly/tools.py in embed(file_owner_or_url, file_id, width, height)
    394         else:
    395             url = file_owner_or_url
--> 396         return PlotlyDisplay(url, width, height)
    397     else:
    398         if (get_config_defaults()['plotly_domain']

~/anaconda3/lib/python3.6/site-packages/plotly/tools.py in __init__(self, url, width, height)
   1438         def __init__(self, url, width, height):
   1439             self.resource = url
-> 1440             self.embed_code = get_embed(url, width=width, height=height)
   1441             super(PlotlyDisplay, self).__init__(data=self.embed_code)
   1442 

~/anaconda3/lib/python3.6/site-packages/plotly/tools.py in get_embed(file_owner_or_url, file_id, width, height)
    299                 "'{1}'."
    300                 "\nRun help on this function for more information."
--> 301                 "".format(url, plotly_rest_url))
    302         urlsplit = six.moves.urllib.parse.urlparse(url)
    303         file_owner = urlsplit.path.split('/')[1].split('~')[1]

PlotlyError: Because you didn't supply a 'file_id' in the call, we're assuming you're trying to snag a figure from a url. You supplied the url, '', we expected it to start with 'https://plot.ly'.
Run help on this function for more information.
In [6]:
import pandas as pd
import matplotlib.pyplot as plt
#from wordcloud import WordCloud, STOPWORDS 
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-89984bd38819> in <module>()
      1 import pandas as pd
      2 import matplotlib.pyplot as plt
----> 3 from wordcloud import WordCloud, STOPWORDS

ModuleNotFoundError: No module named 'wordcloud'
In [10]:
words = pd.read_csv('https://storage.googleapis.com/kaggle-datasets/25491/32521/SW_EpisodeIV.txt?GoogleAccessId=web-data@kaggle-161607.iam.gserviceaccount.com&Expires=1527079018&Signature=lYEXIj7JY1mx0SU%2BOMUMMWFpzmgUWIdPdZTguM9m0hZ0sBrwWDSc20nyiOyJAS4zoOegApSZdNnDVapWpF1DZqAeIuqDalbz5XYsviTrY8pEdQuZEFczj7HnOVBPItdMsMxPFj0bcrb%2Ff%2B4hPrauPftMDdCc1psVpwiUcaAS5NpZ5P60lLmTBmqgSK4ZDvMwa7wZ2b89lzjFVmVUjfHAep5i7DY4xMg4znwVbhjIdZAHvPbu6GkP8ihrdKHcJE7%2B7HdYpbGSfezHrMK7so7Qo6jx9rkQ3TXWzKAO0p80lcRTgIjW6Wr3m9Pzoc4ref37MaXmPRX0bVmkpwFJD%2FBwpA%3D%3D', error_bad_lines=False, sep=' ')
b'Skipping line 555: expected 3 fields, saw 9\n'
In [13]:
words.head()
Out[13]:
character dialogue
1 THREEPIO Did you hear that? They've shut down the main...
2 THREEPIO We're doomed!
3 THREEPIO There'll be no escape for the Princess this time.
4 THREEPIO What's that?
5 THREEPIO I should have known better than to trust the l...
000webhost logo