Last active
May 3, 2018 15:52
-
-
Save jpgard/f41c8f0df631461a94bd4cef6165ccb9 to your computer and use it in GitHub Desktop.
ADSWPY Week 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!pip install html5lib #install html5lib, only needs to be run once | |
#You might need to restart kernel after running with the menu Kernel>Restart | |
import pandas as pd | |
import numpy as np | |
df_power=pd.read_csv('https://proxy.mentoracademy.org/getContentFromUrl/?userid=brooks&url=https%3A%2F%2Fgist.github.com%2Fcab938%2F71e8371ebc621a105afa2181efd78e75%2Fraw%2Ffafe9712373ab5a1d3b2fdb6ac09a28cbcfe8f82%2Fus_power.csv') | |
df_states=pd.read_csv('https://proxy.mentoracademy.org/getContentFromUrl/?userid=brooks&url=https%3A%2F%2Fgist.github.com%2Fcab938%2Ffaedc9046a01b2170c0b252fbc4fc416%2Fraw%2Ff5fa5974e7fef6b996e8ff8583f8d5b47ce391c5%2Fus_states.csv') | |
joined_df= #join frames and only consider places we have data for both the state pop and renewables | |
def pct_renw_by_pop(x): | |
return float(x['renewables in GWh'])/float(x['population']) | |
joined_df['renw_by_pop']= #apply the function above to create a new column of renewables per population | |
joined_df['renw_by_pop_rank']= #determine the ranks for each state in a new column | |
joined_df. #sort data and show the top 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment