Client Module
The client class defines the wbdata client class and associated support classes.
SearchResult
Bases: List
A list that prints out a user-friendly table when printed or returned on the command line
Items are expected to be dict-like and have an "id" key and a "name" or "value" key
Series
Bases: Series
A pandas.Series
with a last_updated
attribute.
The last_updated
attribute is set when the Series
is created but not
automatically updated. Its value is either None
or a datetime.datetime
object.
DataFrame
Bases: DataFrame
__init__(*args, serieses=None, **kwargs)
A pandas.DataFrame
with a last_updated
attribute
The last_updated
attribute is set when the Series is created but not
automatically updated. Its value is a dictionary where the keys are the
column names and the values are None
or a datetime.datetime
object.
Client
dataclass
The client object for the World Bank API.
Most users will only need to create this if they need more than one cache, want to specify a cache programmatically rather than through environment variables, or want to specify a requests Session.
Parameters: |
|
---|
get_data(indicator, country='all', date=None, freq='Y', source=None, parse_dates=False, skip_cache=False)
Retrieve indicators for given countries and years
Parameters: |
|
---|
Returns: |
|
---|
get_sources(source_id=None, skip_cache=False)
Retrieve information on one or more sources
Parameters: |
|
---|
Returns: |
|
---|
get_incomelevels(level_id=None, skip_cache=False)
Retrieve information on one or more income level aggregates
Parameters: |
|
---|
Returns: |
|
---|
get_topics(topic_id=None, skip_cache=False)
Retrieve information on one or more topics
Parameters: |
|
---|
Returns: |
|
---|
get_lendingtypes(type_id=None, skip_cache=False)
Retrieve information on one or more lending type aggregates
Parameters: |
|
---|
Returns: |
|
---|
get_countries(country_id=None, query=None, incomelevel=None, lendingtype=None, skip_cache=False)
Retrieve information on one or more country or regional aggregates.
You can filter your results by specifying query,
incomelevel, or
lendingtype. Specifying
query` will only return countries with
names that match the query as a regular expression. If a string is
supplied, the match is case insensitive.
Specifying query
, incomelevel
, or lendingtype
along with
country_id
will raise a ValueError
.
Parameters: |
|
---|
Returns: |
|
---|
get_indicators(indicator=None, query=None, source=None, topic=None, skip_cache=False)
Retrieve information about an indicator or indicators.
When called with no arguments, returns all indicators. You can specify
one or more indicators to retrieve, or you can specify a source or a
topic for which to list all indicators. Specifying more than one of
indicators
, source
, and topic
will raise a ValueError.
Specifying query
will only return indicators with names that match
the query as a regular expression. If a string is supplied, the match
is case insensitive. Specifying both query
and indicators
will raise
a ValueError.
Parameters: |
|
---|
Returns: |
|
---|
get_series(indicator, country='all', date=None, freq='Y', source=None, parse_dates=False, name='value', keep_levels=False, skip_cache=False)
Retrieve data for a single indicator as a pandas Series.
If pandas is not installed, a RuntimeError will be raised.
Parameters: |
|
---|
Returns: |
|
---|
get_dataframe(indicators, country='all', date=None, freq='Y', source=None, parse_dates=False, keep_levels=False, skip_cache=False)
Download a set of indicators and merge them into a pandas DataFrame.
If pandas is not installed, a RuntimeError will be raised.
Parameters: |
|
---|
Returns: |
|
---|