Country Profiles¶
country_profiles
¶
Country profile download and key indicator functions.
get_cp(country='all', povline=2.15, version=None, ppp_version=2017, release_version=None, api_version=API_VERSION, fmt='arrow', simplify=True, server=None, dataframe_type='pandas')
¶
Download country profile data.
Mirrors pipr::get_cp().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country
|
str | list[str]
|
ISO3 country code(s) or |
'all'
|
povline
|
float | None
|
Poverty line in 2017 PPP USD per day (default 2.15).
When |
2.15
|
version
|
str | None
|
Data version string. |
None
|
ppp_version
|
int
|
PPP base year (default 2017). |
2017
|
release_version
|
str | None
|
Release date in |
None
|
api_version
|
str
|
API version. |
API_VERSION
|
fmt
|
str
|
Response format — |
'arrow'
|
simplify
|
bool
|
If |
True
|
server
|
str | None
|
Server target — |
None
|
dataframe_type
|
Literal['pandas', 'polars']
|
|
'pandas'
|
Returns:
| Type | Description |
|---|---|
DataFrame | PIPResponse
|
A DataFrame of country profile data. |
Example
import povineq df = povineq.get_cp(country="AGO") df_all = povineq.get_cp()
Source code in src/povineq/country_profiles.py
get_cp_ki(country, povline=2.15, version=None, ppp_version=2017, release_version=None, api_version=API_VERSION, simplify=True, server=None, dataframe_type='pandas')
¶
Get country profile key indicators.
Mirrors pipr::get_cp_ki(). When simplify is True,
calls :func:unnest_ki to flatten the nested response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country
|
str
|
Single ISO3 country code (required). |
required |
povline
|
float | None
|
Poverty line in 2017 PPP USD per day (default 2.15).
When |
2.15
|
version
|
str | None
|
Data version string. |
None
|
ppp_version
|
int
|
PPP base year (default 2017). |
2017
|
release_version
|
str | None
|
Release date in |
None
|
api_version
|
str
|
API version. |
API_VERSION
|
simplify
|
bool
|
If |
True
|
server
|
str | None
|
Server target. |
None
|
dataframe_type
|
Literal['pandas', 'polars']
|
|
'pandas'
|
Returns:
| Type | Description |
|---|---|
DataFrame | PIPResponse
|
A flat DataFrame of key indicators when simplify is |
DataFrame | PIPResponse
|
class: |
Raises:
| Type | Description |
|---|---|
PIPValidationError
|
If country is missing or is a list. |
Example
import povineq df = povineq.get_cp_ki(country="IDN")
Source code in src/povineq/country_profiles.py
unnest_ki(raw)
¶
Flatten nested key-indicator response into a single DataFrame.
Mirrors pipr::unnest_ki(). Extracts headcount, population, GNI,
GDP growth, MPM headcount, and shared prosperity tables from the nested
JSON structure and merges them on (country_code, reporting_year).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
dict | list
|
Parsed JSON from the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A flat :class: |
DataFrame
|
|
Example
import povineq df = povineq.get_cp_ki(country="IDN") # calls unnest_ki internally
Source code in src/povineq/country_profiles.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |