Created
July 9, 2020 06:09
-
-
Save MaxGhenis/3701b4bad827ea545ece2bcb8805d6fc to your computer and use it in GitHub Desktop.
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
# Sphinx version: 2.4.4 | |
# Python version: 3.7.7 (CPython) | |
# Docutils version: 0.16 release | |
# Jinja2 version: 2.11.2 | |
# Last messages: | |
# Running Sphinx v2.4.4 | |
# making output directory... | |
# done | |
# building [mo]: targets for 0 po files that are out of date | |
# building [html]: targets for 2 source files that are out of date | |
# updating environment: | |
# [new config] | |
# 2 added, 2 changed, 0 removed | |
# reading sources... [ 50%] 20200707/adult_child_ubi | |
# Executing: 20200707/adult_child_ubi | |
# Loaded extensions: | |
# sphinx.ext.mathjax (2.4.4) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/ext/mathjax.py | |
# sphinxcontrib.applehelp (1.0.2) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinxcontrib/applehelp/__init__.py | |
# sphinxcontrib.devhelp (1.0.2) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinxcontrib/devhelp/__init__.py | |
# sphinxcontrib.htmlhelp (1.0.3) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinxcontrib/htmlhelp/__init__.py | |
# sphinxcontrib.serializinghtml (1.1.4) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py | |
# sphinxcontrib.qthelp (1.0.3) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinxcontrib/qthelp/__init__.py | |
# alabaster (0.7.12) from /home/mghenis/anaconda3/lib/python3.7/site-packages/alabaster/__init__.py | |
# sphinx_togglebutton (0.2.0) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx_togglebutton/__init__.py | |
# sphinx_copybutton (0.2.12) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx_copybutton/__init__.py | |
# jupyter_sphinx (0.2.4) from /home/mghenis/anaconda3/lib/python3.7/site-packages/jupyter_sphinx/__init__.py | |
# myst_nb (0.8.3) from /home/mghenis/anaconda3/lib/python3.7/site-packages/myst_nb/__init__.py | |
# jupyter_book (0.7.0) from /home/mghenis/anaconda3/lib/python3.7/site-packages/jupyter_book/__init__.py | |
# sphinxcontrib.bibtex (unknown version) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinxcontrib/bibtex/__init__.py | |
# sphinx_book_theme (unknown version) from /home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx_book_theme/__init__.py | |
# pydata_sphinx_theme (unknown version) from /home/mghenis/anaconda3/lib/python3.7/site-packages/pydata_sphinx_theme/__init__.py | |
Traceback (most recent call last): | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/jupyter_book/sphinx.py", line 222, in build_sphinx | |
app.build(force_all, filenames) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/application.py", line 349, in build | |
self.builder.build_update() | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299, in build_update | |
len(to_build)) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 311, in build | |
updated_docnames = set(self.read()) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 418, in read | |
self._read_serial(docnames) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 439, in _read_serial | |
self.read_doc(docname) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 479, in read_doc | |
doctree = read_doc(self.app, self.env, self.env.doc2path(docname)) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/io.py", line 316, in read_doc | |
pub.publish() | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/docutils/core.py", line 218, in publish | |
self.settings) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/sphinx/io.py", line 130, in read | |
self.parse() | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/docutils/readers/__init__.py", line 77, in parse | |
self.parser.parse(self.input, document) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/myst_nb/parser.py", line 65, in parse | |
ntbk = add_notebook_outputs(self.env, ntbk) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/myst_nb/cache.py", line 149, in add_notebook_outputs | |
ntbk = execute(ntbk, cwd=Path(file_path).parent) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/nbclient/client.py", line 968, in execute | |
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute() | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/nbclient/util.py", line 72, in wrapped | |
return just_run(coro(*args, **kwargs)) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/nbclient/util.py", line 51, in just_run | |
return loop.run_until_complete(coro) | |
File "/home/mghenis/anaconda3/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete | |
return future.result() | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/nbclient/client.py", line 509, in async_execute | |
cell, index, execution_count=self.code_cells_executed + 1 | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/nbclient/client.py", line 747, in async_execute_cell | |
self._check_raise_for_error(cell, exec_reply) | |
File "/home/mghenis/anaconda3/lib/python3.7/site-packages/nbclient/client.py", line 671, in _check_raise_for_error | |
raise CellExecutionError.from_cell_and_msg(cell, exec_reply['content']) | |
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell: | |
------------------ | |
### LOAD PACKAGES #### | |
import pandas as pd | |
import numpy as np | |
import plotly.express as px | |
import plotly | |
### LOAD DATA ### | |
person_raw = pd.read_csv('https://github.com/MaxGhenis/datarepo/raw/master/pppub19.csv.gz', | |
usecols=['MARSUPWT', 'SPM_ID', 'SPM_POVTHRESHOLD', | |
'SPM_RESOURCES', 'A_AGE']) | |
### PREPROCESS ### | |
person = person_raw.copy(deep=True) | |
person.columns = person.columns.str.lower() | |
person['weight'] = person.marsupwt/100 | |
#Compute total children and adults in each resource sharing group. | |
person['child'] = person.a_age < 18 | |
person['adult'] = person.a_age >= 18 | |
spmu_ages = person.groupby('spm_id')[['child','adult']].sum() | |
spmu_ages.columns = ['children', 'total_adults'] | |
person2 = person.merge(spmu_ages,left_on='spm_id', right_index=True) | |
total_children = (person2.child * person2.weight).sum() | |
total_adults = (person2.adult * person2.weight).sum() | |
### CALCULATIONS ### | |
child_allowance_overall = [] | |
child_allowance_child = [] | |
child_allowance_adults = [] | |
# Determine the poverty rate impact of a Child Allownace from $0 in new spending to $1 trillion. | |
for spending in range(0, 1000000000001, 50000000000): | |
child_allowance_per_child = spending/total_children | |
total_child_allowance = person2.children * child_allowance_per_child | |
new_spm_resources_ca = person2.spm_resources + total_child_allowance | |
new_poor_ca = new_spm_resources_ca < person2.spm_povthreshold | |
new_total_child_poor = ((person2.child * person2.weight * | |
new_poor_ca).sum()) | |
new_child_poverty_rate = ((new_total_child_poor)/ | |
(person2.child * person2.weight).sum()) | |
new_total_adult_poor = ((person2.adult * person2.weight * | |
new_poor_ca).sum()) | |
new_adult_poverty_rate = ((new_total_adult_poor)/ | |
(person2.adult * person2.weight).sum()) | |
new_total_poor_ca = (new_poor_ca * person2.weight).sum() | |
new_poverty_rate_ca = new_total_poor_ca/person2.weight.sum() | |
child_allowance_overall.append(new_poverty_rate_ca) | |
child_allowance_child.append(new_child_poverty_rate) | |
child_allowance_adults.append(new_adult_poverty_rate) | |
ubi_adults_overall = [] | |
ubi_adults_child = [] | |
ubi_adults_adults = [] | |
# Determine the poverty rate impact of a Adult UBI from $0 in new spending to $1 trillion. | |
for spending in range(0, 1000000000001, 50000000000): | |
adult_ubi = spending/total_adults | |
total_adult_ubi = person2.total_adults * adult_ubi | |
new_spm_resources_ubi = person2.spm_resources + total_adult_ubi | |
new_poor_ubi = new_spm_resources_ubi < person2.spm_povthreshold | |
new_total_child_poor = ((person2.child * person2.weight * | |
new_poor_ubi).sum()) | |
new_child_poverty_rate = ((new_total_child_poor)/ | |
(person2.child * person2.weight).sum()) | |
new_total_adult_poor = ((person2.adult * person2.weight * | |
new_poor_ubi).sum()) | |
new_adult_poverty_rate = ((new_total_adult_poor)/ | |
(person2.adult * person2.weight).sum()) | |
new_total_poor_ubi = (new_poor_ubi * person2.weight).sum() | |
new_poverty_rate_ubi = new_total_poor_ubi/person2.weight.sum() | |
ubi_adults_overall.append(new_poverty_rate_ubi) | |
ubi_adults_child.append(new_child_poverty_rate) | |
ubi_adults_adults.append(new_adult_poverty_rate) | |
ubi_all_overall = [] | |
ubi_all_child = [] | |
ubi_all_adults = [] | |
# Determine the poverty rate impact of a All UBI from $0 in new spending to $1 trillion. | |
for spending in range(0, 1000000000001, 50000000000): | |
all_ubi_per_person = spending/(total_adults + total_children) | |
total_all_ubi = ((person2.children * all_ubi_per_person) + | |
(person2.total_adults * all_ubi_per_person)) | |
new_spm_resources_all_ubi = person2.spm_resources + total_all_ubi | |
new_poor_all_ubi = new_spm_resources_all_ubi < person2.spm_povthreshold | |
new_total_child_poor = ((person2.child * person2.weight * | |
new_poor_all_ubi).sum()) | |
new_child_poverty_rate = ((new_total_child_poor)/ | |
(person2.child * person2.weight).sum()) | |
new_total_adult_poor = ((person2.adult * person2.weight * | |
new_poor_all_ubi).sum()) | |
new_adult_poverty_rate = ((new_total_adult_poor)/ | |
(person2.adult * person2.weight).sum()) | |
new_total_poor_all_ubi = (new_poor_all_ubi * person2.weight).sum() | |
new_poverty_rate_all_ubi = new_total_poor_all_ubi/person2.weight.sum() | |
ubi_all_overall.append(new_poverty_rate_all_ubi) | |
ubi_all_child.append(new_child_poverty_rate) | |
ubi_all_adults.append(new_adult_poverty_rate) | |
spending_data = [] | |
for spending in range(0, 1001, 50): | |
spending = spending/100 | |
spending_data.append(spending) | |
### ANALYSIS ### | |
# Create a DataFrame grouped by each plans impact on the overall poverty rate. | |
overall = {'spending_in_billions': spending_data, | |
'child_allowance': child_allowance_overall, | |
'adult_ubi': ubi_adults_overall, | |
'all_ubi': ubi_all_overall} | |
overall_df = pd.DataFrame(overall) | |
overall_df = pd.DataFrame(overall_df).round(3) | |
# Create a DataFrame grouped by each plans impact on the child poverty rate. | |
child = {'spending_in_billions': spending_data, | |
'child_allowance': child_allowance_child, | |
'adult_ubi': ubi_adults_child, | |
'all_ubi': ubi_all_child} | |
child_df = pd.DataFrame(child) | |
child_df = pd.DataFrame(child_df).round(3) | |
# Create a DataFrame grouped by each plans impact on the adult poverty rate. | |
adult = {'spending_in_billions': spending_data, | |
'child_allowance': child_allowance_adults, | |
'adult_ubi': ubi_adults_adults, | |
'all_ubi': ubi_all_adults} | |
adult_df = pd.DataFrame(adult) | |
adult_df = pd.DataFrame(adult_df).round(3) | |
# Join different programs together for plotly. | |
program = (pd.melt(overall_df, 'spending_in_billions', | |
var_name='ubi_type',value_name='poverty_rate')) | |
def melt_dict(d): | |
""" produce long version of data frame represented by dictionary (d). | |
Arguments | |
d: Dictionary where each element represents a differnt UBI type and spending levels and the poverty impacts. | |
Returns | |
DataFrame where every row is the combination of UBI type and spending level. | |
""" | |
df = pd.DataFrame(d).round(3) * 100 | |
program = pd.melt(df, 'spending_in_billions', var_name='ubi_type',value_name='poverty_rate') | |
program['ubi_type'] = program.ubi_type.map({'child_allowance': 'Child allowance', | |
'adult_ubi': 'Adult UBI', | |
'all_ubi': 'All UBI'}) | |
return program | |
program_overall = melt_dict(overall) | |
program_child = melt_dict(child) | |
program_adult = melt_dict(adult) | |
def line_graph(df, x, y, color, title, xaxis_title, yaxis_title): | |
"""Style for line graphs. | |
Arguments | |
df: DataFrame with data to be plotted. | |
x: The string representing the column in df that holds the new spending in billions. | |
y: The string representing the column in df that holds the poverty rate. | |
color: The string representing the UBI type. | |
xaxis_title: The string represnting the xaxis-title. | |
yaxis_title: The string representing the yaxis-title. | |
Returns | |
Nothing. Shows the plot. | |
""" | |
fig = px.line(df, x=x, y=y, color=color) | |
fig.update_layout( | |
title=title, | |
xaxis_title=xaxis_title, | |
yaxis_title=yaxis_title, | |
yaxis_ticksuffix='%', | |
font=dict(family='Roboto'), | |
hovermode='x', | |
xaxis_tickprefix='$', | |
xaxis_ticksuffix='B', | |
plot_bgcolor='white', | |
legend_title_text='' | |
) | |
fig.update_traces(mode='markers+lines', hovertemplate=None) | |
fig.show() | |
line_graph(df=program_overall, x='spending_in_billions', | |
y='poverty_rate', color='ubi_type', | |
title='Overall poverty rate and spending on cash transfer programs', | |
xaxis_title='Spending in billions', | |
yaxis_title='SPM poverty rate') | |
------------------ | |
[0;31m---------------------------------------------------------------------------[0m | |
[0;31mgaierror[0m Traceback (most recent call last) | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mdo_open[0;34m(self, http_class, req, **http_conn_args)[0m | |
[1;32m 1318[0m h.request(req.get_method(), req.selector, req.data, headers, | |
[0;32m-> 1319[0;31m encode_chunked=req.has_header('Transfer-encoding')) | |
[0m[1;32m 1320[0m [0;32mexcept[0m [0mOSError[0m [0;32mas[0m [0merr[0m[0;34m:[0m [0;31m# timeout error[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36mrequest[0;34m(self, method, url, body, headers, encode_chunked)[0m | |
[1;32m 1251[0m [0;34m"""Send a complete request to the server."""[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m-> 1252[0;31m [0mself[0m[0;34m.[0m[0m_send_request[0m[0;34m([0m[0mmethod[0m[0;34m,[0m [0murl[0m[0;34m,[0m [0mbody[0m[0;34m,[0m [0mheaders[0m[0;34m,[0m [0mencode_chunked[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 1253[0m [0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36m_send_request[0;34m(self, method, url, body, headers, encode_chunked)[0m | |
[1;32m 1297[0m [0mbody[0m [0;34m=[0m [0m_encode[0m[0;34m([0m[0mbody[0m[0;34m,[0m [0;34m'body'[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m-> 1298[0;31m [0mself[0m[0;34m.[0m[0mendheaders[0m[0;34m([0m[0mbody[0m[0;34m,[0m [0mencode_chunked[0m[0;34m=[0m[0mencode_chunked[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 1299[0m [0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36mendheaders[0;34m(self, message_body, encode_chunked)[0m | |
[1;32m 1246[0m [0;32mraise[0m [0mCannotSendHeader[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m-> 1247[0;31m [0mself[0m[0;34m.[0m[0m_send_output[0m[0;34m([0m[0mmessage_body[0m[0;34m,[0m [0mencode_chunked[0m[0;34m=[0m[0mencode_chunked[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 1248[0m [0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36m_send_output[0;34m(self, message_body, encode_chunked)[0m | |
[1;32m 1025[0m [0;32mdel[0m [0mself[0m[0;34m.[0m[0m_buffer[0m[0;34m[[0m[0;34m:[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m | |
[0;32m-> 1026[0;31m [0mself[0m[0;34m.[0m[0msend[0m[0;34m([0m[0mmsg[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 1027[0m [0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36msend[0;34m(self, data)[0m | |
[1;32m 965[0m [0;32mif[0m [0mself[0m[0;34m.[0m[0mauto_open[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 966[0;31m [0mself[0m[0;34m.[0m[0mconnect[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 967[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36mconnect[0;34m(self)[0m | |
[1;32m 1413[0m [0;34m[0m[0m | |
[0;32m-> 1414[0;31m [0msuper[0m[0;34m([0m[0;34m)[0m[0;34m.[0m[0mconnect[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 1415[0m [0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/http/client.py[0m in [0;36mconnect[0;34m(self)[0m | |
[1;32m 937[0m self.sock = self._create_connection( | |
[0;32m--> 938[0;31m (self.host,self.port), self.timeout, self.source_address) | |
[0m[1;32m 939[0m [0mself[0m[0;34m.[0m[0msock[0m[0;34m.[0m[0msetsockopt[0m[0;34m([0m[0msocket[0m[0;34m.[0m[0mIPPROTO_TCP[0m[0;34m,[0m [0msocket[0m[0;34m.[0m[0mTCP_NODELAY[0m[0;34m,[0m [0;36m1[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/socket.py[0m in [0;36mcreate_connection[0;34m(address, timeout, source_address)[0m | |
[1;32m 706[0m [0merr[0m [0;34m=[0m [0;32mNone[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 707[0;31m [0;32mfor[0m [0mres[0m [0;32min[0m [0mgetaddrinfo[0m[0;34m([0m[0mhost[0m[0;34m,[0m [0mport[0m[0;34m,[0m [0;36m0[0m[0;34m,[0m [0mSOCK_STREAM[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 708[0m [0maf[0m[0;34m,[0m [0msocktype[0m[0;34m,[0m [0mproto[0m[0;34m,[0m [0mcanonname[0m[0;34m,[0m [0msa[0m [0;34m=[0m [0mres[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/socket.py[0m in [0;36mgetaddrinfo[0;34m(host, port, family, type, proto, flags)[0m | |
[1;32m 751[0m [0maddrlist[0m [0;34m=[0m [0;34m[[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 752[0;31m [0;32mfor[0m [0mres[0m [0;32min[0m [0m_socket[0m[0;34m.[0m[0mgetaddrinfo[0m[0;34m([0m[0mhost[0m[0;34m,[0m [0mport[0m[0;34m,[0m [0mfamily[0m[0;34m,[0m [0mtype[0m[0;34m,[0m [0mproto[0m[0;34m,[0m [0mflags[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 753[0m [0maf[0m[0;34m,[0m [0msocktype[0m[0;34m,[0m [0mproto[0m[0;34m,[0m [0mcanonname[0m[0;34m,[0m [0msa[0m [0;34m=[0m [0mres[0m[0;34m[0m[0;34m[0m[0m | |
[0;31mgaierror[0m: [Errno -2] Name or service not known | |
During handling of the above exception, another exception occurred: | |
[0;31mURLError[0m Traceback (most recent call last) | |
[0;32m<ipython-input-1-c893d11fa016>[0m in [0;36m<module>[0;34m[0m | |
[1;32m 10[0m person_raw = pd.read_csv('https://github.com/MaxGhenis/datarepo/raw/master/pppub19.csv.gz', | |
[1;32m 11[0m usecols=['MARSUPWT', 'SPM_ID', 'SPM_POVTHRESHOLD', | |
[0;32m---> 12[0;31m 'SPM_RESOURCES', 'A_AGE']) | |
[0m[1;32m 13[0m [0;34m[0m[0m | |
[1;32m 14[0m [0;31m### PREPROCESS ###[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py[0m in [0;36mparser_f[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)[0m | |
[1;32m 674[0m ) | |
[1;32m 675[0m [0;34m[0m[0m | |
[0;32m--> 676[0;31m [0;32mreturn[0m [0m_read[0m[0;34m([0m[0mfilepath_or_buffer[0m[0;34m,[0m [0mkwds[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 677[0m [0;34m[0m[0m | |
[1;32m 678[0m [0mparser_f[0m[0;34m.[0m[0m__name__[0m [0;34m=[0m [0mname[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py[0m in [0;36m_read[0;34m(filepath_or_buffer, kwds)[0m | |
[1;32m 429[0m [0;31m# See https://github.com/python/mypy/issues/1297[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 430[0m fp_or_buf, _, compression, should_close = get_filepath_or_buffer( | |
[0;32m--> 431[0;31m [0mfilepath_or_buffer[0m[0;34m,[0m [0mencoding[0m[0;34m,[0m [0mcompression[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 432[0m ) | |
[1;32m 433[0m [0mkwds[0m[0;34m[[0m[0;34m"compression"[0m[0;34m][0m [0;34m=[0m [0mcompression[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/io/common.py[0m in [0;36mget_filepath_or_buffer[0;34m(filepath_or_buffer, encoding, compression, mode)[0m | |
[1;32m 170[0m [0;34m[0m[0m | |
[1;32m 171[0m [0;32mif[0m [0misinstance[0m[0;34m([0m[0mfilepath_or_buffer[0m[0;34m,[0m [0mstr[0m[0;34m)[0m [0;32mand[0m [0mis_url[0m[0;34m([0m[0mfilepath_or_buffer[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 172[0;31m [0mreq[0m [0;34m=[0m [0murlopen[0m[0;34m([0m[0mfilepath_or_buffer[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 173[0m [0mcontent_encoding[0m [0;34m=[0m [0mreq[0m[0;34m.[0m[0mheaders[0m[0;34m.[0m[0mget[0m[0;34m([0m[0;34m"Content-Encoding"[0m[0;34m,[0m [0;32mNone[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 174[0m [0;32mif[0m [0mcontent_encoding[0m [0;34m==[0m [0;34m"gzip"[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/io/common.py[0m in [0;36murlopen[0;34m(*args, **kwargs)[0m | |
[1;32m 139[0m [0;32mimport[0m [0murllib[0m[0;34m.[0m[0mrequest[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 140[0m [0;34m[0m[0m | |
[0;32m--> 141[0;31m [0;32mreturn[0m [0murllib[0m[0;34m.[0m[0mrequest[0m[0;34m.[0m[0murlopen[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 142[0m [0;34m[0m[0m | |
[1;32m 143[0m [0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36murlopen[0;34m(url, data, timeout, cafile, capath, cadefault, context)[0m | |
[1;32m 220[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 221[0m [0mopener[0m [0;34m=[0m [0m_opener[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 222[0;31m [0;32mreturn[0m [0mopener[0m[0;34m.[0m[0mopen[0m[0;34m([0m[0murl[0m[0;34m,[0m [0mdata[0m[0;34m,[0m [0mtimeout[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 223[0m [0;34m[0m[0m | |
[1;32m 224[0m [0;32mdef[0m [0minstall_opener[0m[0;34m([0m[0mopener[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mopen[0;34m(self, fullurl, data, timeout)[0m | |
[1;32m 529[0m [0;32mfor[0m [0mprocessor[0m [0;32min[0m [0mself[0m[0;34m.[0m[0mprocess_response[0m[0;34m.[0m[0mget[0m[0;34m([0m[0mprotocol[0m[0;34m,[0m [0;34m[[0m[0;34m][0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 530[0m [0mmeth[0m [0;34m=[0m [0mgetattr[0m[0;34m([0m[0mprocessor[0m[0;34m,[0m [0mmeth_name[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 531[0;31m [0mresponse[0m [0;34m=[0m [0mmeth[0m[0;34m([0m[0mreq[0m[0;34m,[0m [0mresponse[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 532[0m [0;34m[0m[0m | |
[1;32m 533[0m [0;32mreturn[0m [0mresponse[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mhttp_response[0;34m(self, request, response)[0m | |
[1;32m 639[0m [0;32mif[0m [0;32mnot[0m [0;34m([0m[0;36m200[0m [0;34m<=[0m [0mcode[0m [0;34m<[0m [0;36m300[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 640[0m response = self.parent.error( | |
[0;32m--> 641[0;31m 'http', request, response, code, msg, hdrs) | |
[0m[1;32m 642[0m [0;34m[0m[0m | |
[1;32m 643[0m [0;32mreturn[0m [0mresponse[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36merror[0;34m(self, proto, *args)[0m | |
[1;32m 561[0m [0mhttp_err[0m [0;34m=[0m [0;36m0[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 562[0m [0margs[0m [0;34m=[0m [0;34m([0m[0mdict[0m[0;34m,[0m [0mproto[0m[0;34m,[0m [0mmeth_name[0m[0;34m)[0m [0;34m+[0m [0margs[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 563[0;31m [0mresult[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0m_call_chain[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 564[0m [0;32mif[0m [0mresult[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 565[0m [0;32mreturn[0m [0mresult[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36m_call_chain[0;34m(self, chain, kind, meth_name, *args)[0m | |
[1;32m 501[0m [0;32mfor[0m [0mhandler[0m [0;32min[0m [0mhandlers[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 502[0m [0mfunc[0m [0;34m=[0m [0mgetattr[0m[0;34m([0m[0mhandler[0m[0;34m,[0m [0mmeth_name[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 503[0;31m [0mresult[0m [0;34m=[0m [0mfunc[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 504[0m [0;32mif[0m [0mresult[0m [0;32mis[0m [0;32mnot[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 505[0m [0;32mreturn[0m [0mresult[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mhttp_error_302[0;34m(self, req, fp, code, msg, headers)[0m | |
[1;32m 753[0m [0mfp[0m[0;34m.[0m[0mclose[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 754[0m [0;34m[0m[0m | |
[0;32m--> 755[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mparent[0m[0;34m.[0m[0mopen[0m[0;34m([0m[0mnew[0m[0;34m,[0m [0mtimeout[0m[0;34m=[0m[0mreq[0m[0;34m.[0m[0mtimeout[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 756[0m [0;34m[0m[0m | |
[1;32m 757[0m [0mhttp_error_301[0m [0;34m=[0m [0mhttp_error_303[0m [0;34m=[0m [0mhttp_error_307[0m [0;34m=[0m [0mhttp_error_302[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mopen[0;34m(self, fullurl, data, timeout)[0m | |
[1;32m 523[0m [0mreq[0m [0;34m=[0m [0mmeth[0m[0;34m([0m[0mreq[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 524[0m [0;34m[0m[0m | |
[0;32m--> 525[0;31m [0mresponse[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0m_open[0m[0;34m([0m[0mreq[0m[0;34m,[0m [0mdata[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 526[0m [0;34m[0m[0m | |
[1;32m 527[0m [0;31m# post-process response[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36m_open[0;34m(self, req, data)[0m | |
[1;32m 541[0m [0mprotocol[0m [0;34m=[0m [0mreq[0m[0;34m.[0m[0mtype[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 542[0m result = self._call_chain(self.handle_open, protocol, protocol + | |
[0;32m--> 543[0;31m '_open', req) | |
[0m[1;32m 544[0m [0;32mif[0m [0mresult[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 545[0m [0;32mreturn[0m [0mresult[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36m_call_chain[0;34m(self, chain, kind, meth_name, *args)[0m | |
[1;32m 501[0m [0;32mfor[0m [0mhandler[0m [0;32min[0m [0mhandlers[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 502[0m [0mfunc[0m [0;34m=[0m [0mgetattr[0m[0;34m([0m[0mhandler[0m[0;34m,[0m [0mmeth_name[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m--> 503[0;31m [0mresult[0m [0;34m=[0m [0mfunc[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 504[0m [0;32mif[0m [0mresult[0m [0;32mis[0m [0;32mnot[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 505[0m [0;32mreturn[0m [0mresult[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mhttps_open[0;34m(self, req)[0m | |
[1;32m 1360[0m [0;32mdef[0m [0mhttps_open[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mreq[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 1361[0m return self.do_open(http.client.HTTPSConnection, req, | |
[0;32m-> 1362[0;31m context=self._context, check_hostname=self._check_hostname) | |
[0m[1;32m 1363[0m [0;34m[0m[0m | |
[1;32m 1364[0m [0mhttps_request[0m [0;34m=[0m [0mAbstractHTTPHandler[0m[0;34m.[0m[0mdo_request_[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m~/anaconda3/lib/python3.7/urllib/request.py[0m in [0;36mdo_open[0;34m(self, http_class, req, **http_conn_args)[0m | |
[1;32m 1319[0m encode_chunked=req.has_header('Transfer-encoding')) | |
[1;32m 1320[0m [0;32mexcept[0m [0mOSError[0m [0;32mas[0m [0merr[0m[0;34m:[0m [0;31m# timeout error[0m[0;34m[0m[0;34m[0m[0m | |
[0;32m-> 1321[0;31m [0;32mraise[0m [0mURLError[0m[0;34m([0m[0merr[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[0m[1;32m 1322[0m [0mr[0m [0;34m=[0m [0mh[0m[0;34m.[0m[0mgetresponse[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m | |
[1;32m 1323[0m [0;32mexcept[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m | |
[0;31mURLError[0m: <urlopen error [Errno -2] Name or service not known> | |
URLError: <urlopen error [Errno -2] Name or service not known> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment