Last active
March 24, 2022 16:18
-
-
Save earlcharles1/e885f0f53eaec6f3ce17115f479eb6ba to your computer and use it in GitHub Desktop.
Congress API Fetch
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
refer = call() | |
refer |
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
def call(): | |
headers = { | |
'X-API-Key': 'g9Gl5fJh7xzikftE3DNjzLhtq1VLMDxmN0ZxkI6', | |
} | |
params = { | |
'query': '{Oil}', | |
} | |
response = requests.get('https://api.propublica.org/congress/v1/bills/search.json?query={query}', headers=headers, params=params) | |
BillData = response.text | |
# covert to fucking dictionary probably or string | |
x = json.loads(BillData) | |
#normalize data and selects through nests | |
df = pd.json_normalize(x, record_path = ['results','bills']) | |
df_assortment = df[['bill_id', 'title','active','latest_major_action_date','summary','govtrack_url']].sort_values( | |
by = ['active','latest_major_action_date'], ascending = False) | |
return HTML(df_assortment.to_html(escape = False)) |
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
import requests | |
import json | |
import pandas as pd | |
from IPython.display import HTML |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment