Stats¶
stats
¶
Core poverty and inequality statistics functions.
get_stats(country='all', year='all', povline=None, popshare=None, fill_gaps=False, nowcast=False, subgroup=None, welfare_type='all', reporting_level='all', version=None, ppp_version=None, release_version=None, api_version=API_VERSION, fmt='arrow', simplify=True, server=None, dataframe_type='pandas')
¶
Get poverty and inequality statistics from the PIP API.
This is the primary function for querying household survey-based poverty
and inequality estimates. It mirrors pipr::get_stats().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country
|
str | list[str]
|
ISO3 country code(s) or |
'all'
|
year
|
str | int | list[int]
|
Survey year(s) or |
'all'
|
povline
|
float | None
|
Poverty line in 2017 PPP USD per day. |
None
|
popshare
|
float | None
|
Proportion of the population below the poverty line. When set, povline is ignored. |
None
|
fill_gaps
|
bool
|
If |
False
|
nowcast
|
bool
|
If |
False
|
subgroup
|
str | None
|
Pre-defined aggregation. Either |
None
|
welfare_type
|
Literal['all', 'income', 'consumption']
|
Welfare concept — |
'all'
|
reporting_level
|
Literal['all', 'national', 'urban', 'rural']
|
Geographic level — |
'all'
|
version
|
str | None
|
Data version string (see :func: |
None
|
ppp_version
|
int | None
|
PPP base year. |
None
|
release_version
|
str | None
|
Release date in |
None
|
api_version
|
Literal['v1']
|
API version (only |
API_VERSION
|
fmt
|
Literal['arrow', 'json', 'csv']
|
Response format — |
'arrow'
|
simplify
|
bool
|
If |
True
|
server
|
str | None
|
Server target — |
None
|
dataframe_type
|
Literal['pandas', 'polars']
|
|
'pandas'
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
DataFrameLike | PIPResponse
|
class: |
DataFrameLike | PIPResponse
|
class: |
Raises:
| Type | Description |
|---|---|
PIPValidationError
|
If parameter values are invalid. |
PIPAPIError
|
If the API returns a structured error response. |
PIPRateLimitError
|
If the rate limit is exceeded after retries. |
PIPConnectionError
|
If the network is unreachable. |
Example
import povineq df = povineq.get_stats(country="AGO", year=2000) df = povineq.get_stats(country="all", year="all", fill_gaps=True) df = povineq.get_stats(country="all", subgroup="wb_regions")
Source code in src/povineq/stats.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
get_wb(year='all', povline=None, version=None, ppp_version=None, release_version=None, api_version=API_VERSION, fmt='json', simplify=True, server=None, dataframe_type='pandas')
¶
Get World Bank regional and global aggregate statistics.
Shorthand for get_stats(subgroup="wb_regions").
Mirrors pipr::get_wb().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
str | int | list[int]
|
Year(s) or |
'all'
|
povline
|
float | None
|
Poverty line in 2017 PPP USD per day. |
None
|
version
|
str | None
|
Data version string. |
None
|
ppp_version
|
int | None
|
PPP base year. |
None
|
release_version
|
str | None
|
Release date in |
None
|
api_version
|
Literal['v1']
|
API version. |
API_VERSION
|
fmt
|
Literal['json', 'csv']
|
Response format — |
'json'
|
simplify
|
bool
|
If |
True
|
server
|
str | None
|
Server target. |
None
|
dataframe_type
|
Literal['pandas', 'polars']
|
|
'pandas'
|
Returns:
| Type | Description |
|---|---|
DataFrameLike | PIPResponse
|
A DataFrame of WB regional/global aggregates. |
Example
import povineq df = povineq.get_wb()
Source code in src/povineq/stats.py
get_agg(year='all', povline=None, version=None, ppp_version=None, release_version=None, aggregate=None, api_version=API_VERSION, fmt='json', simplify=True, server=None, dataframe_type='pandas')
¶
Get custom aggregate statistics (FCV, regional, vintage, etc.).
Mirrors pipr::get_agg().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
str | int | list[int]
|
Year(s) or |
'all'
|
povline
|
float | None
|
Poverty line in 2017 PPP USD per day. |
None
|
version
|
str | None
|
Data version string. |
None
|
ppp_version
|
int | None
|
PPP base year. |
None
|
release_version
|
str | None
|
Release date in |
None
|
aggregate
|
str | None
|
Aggregate name (e.g. |
None
|
api_version
|
Literal['v1']
|
API version. |
API_VERSION
|
fmt
|
Literal['json', 'csv']
|
Response format — |
'json'
|
simplify
|
bool
|
If |
True
|
server
|
str | None
|
Server target. |
None
|
dataframe_type
|
Literal['pandas', 'polars']
|
|
'pandas'
|
Returns:
| Type | Description |
|---|---|
DataFrameLike | PIPResponse
|
A DataFrame of custom aggregate statistics. |
Example
import povineq df = povineq.get_agg(aggregate="fcv", server="qa")