Skip to content

Conversation

@antaresc
Copy link
Contributor

@antaresc antaresc commented Aug 26, 2019

Implemented get_place_obs in the populations submodule, added unit tests, added documentation.

Reimplemented query as a function instead of a class.

@antaresc antaresc changed the title Implemented get_place_obs Implemented get_place_obs and reimplemented query Aug 26, 2019
... 'placeOfBirth': 'BornInOtherStateInTheUnitedStates'
... }
>>> get_place_obs('City', 'Person', constraining_properties=props)
[
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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': '' ...}, {}]?

'marginOfError': 39,
'measuredProp': 'count',
'measuredValue': 67,
'measurementMethod': 'CenusACS5yrSurvey',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cenus...

Copy link
Contributor

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh gotcha

More precisely, it is a :obj:`dict` from query variable to its value in a
given row.

Yields:
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, changed

Copy link
Contributor

@tjann tjann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query lgtm

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@beets beets left a 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

- 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`.
Copy link
Contributor

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?

Copy link
Contributor Author

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

'marginOfError': 39,
'measuredProp': 'count',
'measuredValue': 67,
'measurementMethod': 'CenusACS5yrSurvey',
Copy link
Contributor

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...

@antaresc antaresc merged commit fe71648 into datacommonsorg:master Aug 27, 2019
antaresc added a commit that referenced this pull request Oct 2, 2019
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants