awherepy.crops¶
A module to access and retrieve aWhere crop data.
-
awherepy.crops.
get_crops
(key, secret, crop_id=None)[source]¶ Retrieve a list of available crops or single crop if specified.
- Parameters
key (str) – API key for a valid aWhere API application.
secret (str) – API secret for a valid aWhere API application.
crop_id (str, optional) – Valid aWhere crop id.
- Returns
crop_df – Dataframe containing a single crop or all available crops.
- Return type
pandas dataframe
Example
>>> # Imports >>> import os >>> import awherepy as aw >>> import awherepy.crops as awc >>> # Get aWhere API key and secret >>> awhere_api_key = os.environ.get('AWHERE_API_KEY') >>> awhere_api_secret = os.environ.get('AWHERE_API_SECRET') >>> # Get all available aWhere crops >>> all_crops = awc.get_crops(awhere_api_key, awhere_api_secret) >>> # Check number of entries >>> len(all_crops) 21 >>> # Get a specific crop >>> corn_2500_gdd = awc.get_crops( >>> awhere_api_key, awhere_api_secret, crop_id='corn-2500-gdd' >>> ) >>> Check number of entries >>> len(corn_2500_gdd) 1