utils
Utility function to interact with framework resources and trends data.
full_metro_area_codes(scope_dir, locations)
Adds country and state codes to metro area codes (e.g., 630
becomes US-AL-630
),
based on scope_dir/locations.txt
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
locations
|
List[str]
|
Locations to potentially prepend full location codes to. |
required |
Examples:
Returns:
Type | Description |
---|---|
List[str]
|
A version of |
Source code in gtrends_collection/utils.py
full_term_names(scope_dir, terms, include_id=True)
Converts topic and category IDs to their full names, based on scope_dir/term_map.csv
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
terms
|
List[str]
|
Terms to be converted. |
required |
Examples:
Returns:
Type | Description |
---|---|
List[str]
|
A version of |
Source code in gtrends_collection/utils.py
read_scope(scope_dir, which)
Reads in a scope file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope_dir
|
str
|
Directory containing scope files. |
required |
which
|
str
|
Name of the file to be read in (e.g., |
required |
Examples:
Returns:
Type | Description |
---|---|
List[str]
|
A list of terms or locations. |