Skip to content

Commit 960b8f1

Browse files
committed
add comments
1 parent d7e5c5b commit 960b8f1

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

groclient/experimental.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def get_data_points(self, **selections):
1313
1414
For example:
1515
16-
- Ontology expansion is under development.
17-
1816
- "Gro derived on-the-fly" is under development.
1917
2018
- Many sources are still under migration (please refer to internal confluence page for source migration timeline)
@@ -114,6 +112,57 @@ def get_data_points(self, **selections):
114112
)
115113

116114
def get_data_points_df(self, **selections):
115+
"""Call :meth:`~groclient.Experimental.get_data_points` and return as a combined
116+
dataframe.
117+
118+
Parameters
119+
----------
120+
metric_id : integer
121+
How something is measured. e.g. "Export Value" or "Area Harvested"
122+
item_ids : integer or list of integers
123+
What is being measured. e.g. "Corn" or "Rainfall"
124+
region_ids : integer or list of integers
125+
Where something is being measured e.g. "United States Corn Belt" or "China"
126+
partner_region_ids : integer or list of integers, optional
127+
partner_region refers to an interaction between two regions, like trade or
128+
transportation. For example, for an Export metric, the "region" would be the exporter
129+
and the "partner_region" would be the importer. For most series, this can be excluded
130+
or set to 0 ("World") by default.
131+
source_id : integer
132+
frequency_id : integer
133+
unit_id : integer, optional
134+
start_date : string, optional
135+
All data points with end dates after this date.
136+
end_date : string, optional
137+
All data points with start dates before this date.
138+
coverage_threshold: float, optional
139+
Custom threshold on the coverage of geospatial data. Value should be between 0 and 1.
140+
141+
Returns
142+
-------
143+
pandas.DataFrame
144+
The results from :meth:`~groclient.Experimental.get_data_points`, appended together
145+
into a single dataframe.
146+
Data point attributes in timestamp format (e.g `start_timestamp`, `end_timestamp`)
147+
will be converted into human readable format (`YYYY-MM-DD`), and renamed as
148+
`start_date`and `end_date`
149+
150+
Example::
151+
from groclient.experimental import Experimental
152+
153+
exp_client = Experimental(access_token="your_token_here")
154+
exp_client.get_data_points_df(
155+
**{
156+
'metric_id': 2540047,
157+
'item_ids': [3457],
158+
'region_ids': [100023971, 100023990],
159+
'frequency_id': 1,
160+
'source_id': 26,
161+
'start_date': '2021-12-20',
162+
'end_date': '2021-12-21',
163+
}
164+
)
165+
"""
117166
res = lib.get_data_points_v2_prime(
118167
self.access_token, self.api_host, **selections
119168
)

0 commit comments

Comments
 (0)