pewresearch / search_sampler Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I've found another potential issue when testing example.py
with all of the default parameters.
When pulling a single sample (Option 1) with 'period_length'
set to 'day'
in the example, the package returns a ValueError:
/search_sampler/venv/bin/python /search_sampler/example.py
INFO: Running period 2017-01-01 - 2017-02-01
Traceback (most recent call last):
File "/search_sampler/example.py", line 40, in <module>
run_pull()
File "/search_sampler/example.py", line 31, in run_pull
df_results = sample.pull_data_from_api(format="dataframe")
File "/search_sampler/__init__.py", line 324, in pull_data_from_api
return pandas.DataFrame(d_results)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/frame.py", line 435, in __init__
mgr = init_dict(data, index, columns, dtype=dtype)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 254, in init_dict
return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 64, in arrays_to_mgr
index = extract_index(arrays)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 355, in extract_index
raise ValueError("If using all scalar values, you must pass an index")
ValueError: If using all scalar values, you must pass an index
Process finished with exit code 1
I've also tried testing this on Python 2.7, but get the same error.
First of all, this is a great package. A big thanks to the talented people at Pew Research for putting this out there.
It seems like the function _get_file_path()
in search_sampler/_init_.py
is rejecting DMA codes since the codes are stored as integers. At line 144:
str_path = os.path.join(self.output_path, self.params["region"])
Issue can be reproduced by running example.py
with the 'region' parameter set to 500
(without quotes):
TypeError: join() argument must be str or bytes, not 'int'
Note that the issue can't be fixed by setting the 'region' parameter to '500'
(as a string) because pull_data_from_api()
requires params['region']
to be an integer.
I've found another potential issue when testing example.py
with all of the default parameters.
When pulling a single sample (Option 1) with 'period_length'
set to 'day'
in the example, the package returns a ValueError:
/search_sampler/venv/bin/python /search_sampler/example.py
INFO: Running period 2017-01-01 - 2017-02-01
Traceback (most recent call last):
File "/search_sampler/example.py", line 40, in <module>
run_pull()
File "/search_sampler/example.py", line 31, in run_pull
df_results = sample.pull_data_from_api(format="dataframe")
File "/search_sampler/__init__.py", line 324, in pull_data_from_api
return pandas.DataFrame(d_results)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/frame.py", line 435, in __init__
mgr = init_dict(data, index, columns, dtype=dtype)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 254, in init_dict
return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 64, in arrays_to_mgr
index = extract_index(arrays)
File "/search_sampler/venv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 355, in extract_index
raise ValueError("If using all scalar values, you must pass an index")
ValueError: If using all scalar values, you must pass an index
Process finished with exit code 1
I've also tried testing this on Python 2.7, but get the same error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.