World Power Consumption in 2014

In [107]:
import plotly.graph_objs as go 
from plotly.offline import init_notebook_mode,iplot
init_notebook_mode(connected=True) 
In [108]:
# Import the dataset
import pandas as pd
df = pd.read_csv('2014_World_Power_Consumption')
df.head(5)
Out[108]:
Country Power Consumption KWH Text
0 China 5.523000e+12 China 5,523,000,000,000
1 United States 3.832000e+12 United 3,832,000,000,000
2 European 2.771000e+12 European 2,771,000,000,000
3 Russia 1.065000e+12 Russia 1,065,000,000,000
4 Japan 9.210000e+11 Japan 921,000,000,000
In [109]:
data = dict(type = 'choropleth',
           colorscale = 'Electric',
           reversescale = True,
           locations = df['Country'],
           locationmode = 'country names',
           z = df['Power Consumption KWH'],
           text = df['Country'],
           colorbar = {'title': '2014 Power Consumption in KWH'})
In [110]:
layout = dict(title = '2014 Power Consumption in KWH',
             geo = dict (showframe = False, projection = {'type': 'natural earth'}))
In [111]:
choromap = go.Figure(data=[data], layout=layout)
In [112]:
iplot(choromap,validate=False)

China and USA were the major power consuming nations in 2014.

2012 General Election Voting Data

In [123]:
elect = pd.read_csv('2012_Election_Data')
In [141]:
elect.head()
Out[141]:
Year ICPSR State Code Alphanumeric State Code State VEP Total Ballots Counted VEP Highest Office VAP Highest Office Total Ballots Counted Highest Office Voting-Eligible Population (VEP) Voting-Age Population (VAP) % Non-citizen Prison Probation Parole Total Ineligible Felon State Abv
0 2012 41 1 Alabama NaN 58.6% 56.0% NaN 2,074,338 3,539,217 3707440.0 2.6% 32,232 57,993 8,616 71,584 AL
1 2012 81 2 Alaska 58.9% 58.7% 55.3% 301,694 300,495 511,792 543763.0 3.8% 5,633 7,173 1,882 11,317 AK
2 2012 61 3 Arizona 53.0% 52.6% 46.5% 2,323,579 2,306,559 4,387,900 4959270.0 9.9% 35,188 72,452 7,460 81,048 AZ
3 2012 42 4 Arkansas 51.1% 50.7% 47.7% 1,078,548 1,069,468 2,109,847 2242740.0 3.5% 14,471 30,122 23,372 53,808 AR
4 2012 71 5 California 55.7% 55.1% 45.1% 13,202,158 13,038,547 23,681,837 28913129.0 17.4% 119,455 0 89,287 208,742 CA
In [168]:
data = dict(type='choropleth',
            colorscale = 'Viridis',
            reversescale = True,
            locations = elect['State Abv'],
            z = elect['Voting-Age Population (VAP)'],
            locationmode = 'USA-states',
            text = elect['State'],
            marker = dict(line = dict(color = 'rgb(12,12,12)',width = 1)),
            colorbar = {'title':"Voting-Age Population (VAP)"}
            ) 
In [169]:
layout = dict(title = '2012 General Election Voting Data',
              geo = dict(scope='usa',showlakes = True, lakecolor = 'rgb(85,173,240)'))
In [170]:
choromap1 = go.Figure(data = [data],layout = layout)
In [171]:
iplot(choromap1)

As we can see California, Texas, New York, and Florida are the major states where voting population resides.