Skip to content

Commit dd5bc43

Browse files
authored
Add measurementMethod to get_related_places() call. (#118)
1 parent 3f96346 commit dd5bc43

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

datacommons/examples/places.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ def main():
4242

4343
# Get related places.
4444
print('Get related places')
45-
related_places = dc.get_related_places(['geoId/06085'], 'Person',
46-
{'age': "Years21To64", "gender": "Female"}, 'count', '')
45+
# TODO(*): s/Cenus/Census/g when data is ready in BT.
46+
related_places = dc.get_related_places(['geoId/06085'], 'Person', 'count',
47+
'CenusACS5yrSurvey', "measuredValue", {"gender": "Female"})
4748
print(related_places)
4849

4950

datacommons/places.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ def get_places_in(dcids, place_type):
7272
return result
7373

7474

75-
def get_related_places(dcids, population_type, constraining_properties={},
76-
measured_property='count',
77-
stat_type='measured', within_place='',
78-
per_capita=False, same_place_type=False):
75+
def get_related_places(dcids, population_type, measured_property,
76+
measurement_method, stat_type, constraining_properties={},
77+
within_place='', per_capita=False, same_place_type=False):
7978
""" Returns :obj:`Place`s related to :code:`dcids` for the given constraints.
8079
8180
Args:
8281
dcids (:obj:`iterable` of :obj:`str`): Dcids to get related places.
8382
population_type (:obj:`str`): The type of statistical population.
83+
measured_property (:obj:`str`): The measured property.
84+
measurement_method(:obj:`str`): The measurement method for the observation.
85+
stat_type (:obj:`str`): The statistical type for the observation.
8486
constraining_properties (:obj:`map` from :obj:`str` to :obj:`str`, optional):
8587
A map from constraining property to the value that the
8688
:obj:`StatisticalPopulation` should be constrained by.
87-
measured_property (:obj:`str`): The measured property.
88-
stat_type (:obj:`str`): The statistical type for the observation.
8989
within_place(:obj:`str`): Optional, the DCID of the place that all the
9090
related places are contained in.
9191
per_capita(:obj:`bool`): Optional, whether to take into account
@@ -109,7 +109,7 @@ def get_related_places(dcids, population_type, constraining_properties={},
109109
>>> get_related_places(["geoId/06"], "Person", {
110110
"age": "Years21To64",
111111
"gender": "Female"
112-
}, "count", "measured")
112+
}, "count", "CenusACS5yrSurvey", "measuredValue")
113113
{
114114
'geoId/06085': [
115115
'geoId/06041',
@@ -130,6 +130,7 @@ def get_related_places(dcids, population_type, constraining_properties={},
130130
'pvs': pvs,
131131
'measuredProperty': measured_property,
132132
'statType': '', # TODO: Set to stat_type when having it in BT data.
133+
'measurementMethod': measurement_method,
133134
'withinPlace': within_place,
134135
'perCapita': per_capita,
135136
'samePlaceType': same_place_type,

0 commit comments

Comments
 (0)