query¶
The data.query
module provides a function that calls and combines data from Wikidata
Note: the purpose of this module is for a wikirepo.data.query() function call
Functions
- wikirepo.data.query.query(ents_dict=None, locations=None, depth=None, timespan=None, interval=None, climate_props=None, demographic_props=None, economic_props=None, electoral_poll_props=None, electoral_result_props=None, geographic_props=None, institutional_props=None, political_props=None, misc_props=None, verbose=True)[source]¶
Queries Wikidata properties based on module arguments for locations given a depth, interval, and timespan.
- Parameters:
- ents_dictwd_utils.EntitiesDictoptional (default=None)
A dictionary with keys being Wikidata QIDs and values being their entities.
- locationsstr, list, or lctn_utils.LocationsDict (contains strs)optional (default=None)
The locations to query either as strings for indexed locations or Wikidata QIDs.
- depthint (default=0, no sub_locations)
The depth from the given lbls or qids that data should go.
Note: this uses ‘P150’ (contains administrative territorial entity).
- timespantwo element tuple or listcontains datetime.date or tuple (default=None: (date.today(), date.today())).
A tuple or list that defines the start and end dates to be queried.
Note 1: if None, then only the most recent data for the interval will be queried.
Note 2: if True, then the full timespan from 1-1-1 to the current day will be queried.
Note 3: passing a single entry will query for that date only.
- intervalstr (default=None)
The time interval over which queries will be made.
Note 1: see data.time_utils for options.
Note 2: if None, then only the most recent data will be queried.
- climate_propsstr or list (contains strs)optional (default=None)
String representations of data/climate modules for data_utils.query_repo_dir.
- demographic_propsstr or list (contains strs)optional (default=None)
String representations of data/demographic modules for data_utils.query_repo_dir.
- economic_propsstr or list (contains strs)optional (default=None)
String representations of data/economic modules for data_utils.query_repo_dir.
- electoral_poll_propsstr or list (contains strs)optional (default=None)
String representations of data/electoral_polls modules for data_utils.query_repo_dir.
- electoral_result_propsstr or list (contains strs)optional (default=None)
String representations of data/electoral_results modules for data_utils.query_repo_dir.
- geographic_propsstr or list (contains strs)optional (default=None)
String representations of data/geographic modules for data_utils.query_repo_dir.
- institutional_propsstr or list (contains strs)optional (default=None)
String representations of data/institutional modules for data_utils.query_repo_dir.
- political_propsstr or list (contains strs)optional (default=None)
String representations of data/political modules for data_utils.query_repo_dir.
- misc_propsstr or list (contains strs)optional (default=None)
String representations of data/misc (miscellaneous) modules for data_utils.query_repo_dir.
- verbosebool (default=True)
Whether to show a tqdm progress bar for the query Note: passing ‘full’ calls progress bars for each data_utils.query_repo_dir.
- Potential later arguments:
- multicorebool or int (default=False)
Whether to make use of multiple processes and threads, and how many to use Note: True uses all available.
- sourcebool (default=False)
Whether to add columns for sources for all data.
- Returns:
- df_mergepd.DataFrame
A df of locations and data given timespan and data source arguments.