-
Notifications
You must be signed in to change notification settings - Fork 46
Implemented get_place_obs and reimplemented query #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ... 'placeOfBirth': 'BornInOtherStateInTheUnitedStates' | ||
| ... } | ||
| >>> get_place_obs('City', 'Person', constraining_properties=props) | ||
| [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a {} to hold per place data in the example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_pop_obs returns a list of place observations instead of a dict keyed by place. This is since places is the only key in what's returned by the REST API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you check the example in here: https://github.com/datacommonsorg/api-python/pull/94/files#diff-f06c30a8f8b853dcf991f4addad79d9fR144
It should be [{'name':xxx, 'place': '' ...}, {}]?
datacommons/populations.py
Outdated
| 'marginOfError': 39, | ||
| 'measuredProp': 'count', | ||
| 'measuredValue': 67, | ||
| 'measurementMethod': 'CenusACS5yrSurvey', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cenus...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG it's actually in our raw MCF data...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh gotcha
datacommons/query.py
Outdated
| More precisely, it is a :obj:`dict` from query variable to its value in a | ||
| given row. | ||
|
|
||
| Yields: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might just do return since we don't stream the results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also prefer return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, changed
tjann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query lgtm
datacommons/query.py
Outdated
| that returns true if and only if a row in the query results should be | ||
| kept. The argument for this function is a row returned by :code:`query`. | ||
| More precisely, it is a :obj:`dict` from query variable to its value in a | ||
| given row. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A filter function that will help select rows returned by the SPARQL query by evaluating each row as its argument, and returning true if and only if the row satisfies the function. More precisely, this function takes a single variable, which is a n :obj:dict returned from the query variable to its value for a given row.
Not sure if this is better, but in general this section is a bit confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
A function that
that selects rows to be returned by :code:`query`. This function should
accept a row in the results of executing :code:`query_string` and return
True if and only if the row is to be returned by :code:`query`. The row
passed in as an argument is represented as a :obj:`dict` that maps a
query variable in :code:`query_string` to its value in the given row.
beets
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm pending other comment resolutions
datacommons/populations.py
Outdated
| - one of: :code:`measuredValue`, :code:`meanValue`, :code:`maxValue`, | ||
| :code:`minValue`, :code:`medianValue` | ||
| :code:`minValue`, :code:`medianValue`: Fields that denote values measured | ||
| by the :obj:`Observation`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also things like sumValue, stdError, etc. Probably refer to Observation table for a complete list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I added the others from the Observation table
datacommons/populations.py
Outdated
| 'marginOfError': 39, | ||
| 'measuredProp': 'count', | ||
| 'measuredValue': 67, | ||
| 'measurementMethod': 'CenusACS5yrSurvey', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG it's actually in our raw MCF data...
* Fix typo in places.py. (#71) (#84) * Added iPynb notebooks and fixed issue #67 (#86) * Added notebooks * Added --upgrade flag * Update requirements and setup.py * Added maintenance information to the readme * Update setup.py and pypi long description (#87) * Update setup.py and requirements * Add long description for pypi package * Use README.md as the long description * Use single quote * Fixed docs and updated changelog (#89) * Amended documentation for creating a key. * Updated CHANGELOG * Spacing * Added 0.4.3 changes * Added 0.x to changelog * Add get_pop_obs api (#93) * Add get_pop_obs api * Updated comments with more detailed description. * Update comment and rst file * Updated comments * Move to populations module * Add missing change * Correct typo * More typo correction * Add comments on observations field * Add the step to join google group (#95) * Add more details for joining google group (#96) * Implemented get_place_obs and reimplemented query (#94) * Implemented get_place_obs * Reimplemented query as a function instead of a class. * query now returns a list. Amended docstrings. * Fixed docstring typo * Add observation_date as argument to get_place_obs (#97) * Add observation_date as argument to get_place_obs * Update doc string * Update test * fix link to getting started on read the docs home page (#98) * Fixed bug regarding indexing (#100) * Updated the changelog (#101)
Implemented
get_place_obsin thepopulationssubmodule, added unit tests, added documentation.Reimplemented
queryas a function instead of a class.