Motivation
Setup
WBGAPI library
Sources
Economies
BGD
Bangladesh
False
BGR
Bulgaria
False
BHR
Bahrain
False
BHS
Bahamas, The
False
BIH
Bosnia and Herzegovina
False
BLR
Belarus
False
BLZ
Belize
False
BMU
Bermuda
False
BOL
Bolivia
False
BRA
Brazil
False
Regions
AGO
23356247
25107925
BDI
8675606
9245992
BEN
9199254
9729254
BFA
15605211
16571252
BWA
1987106
2039551
CAF
4386765
4436411
CIV
20532944
21547188
CMR
20341236
21485267
COD
64563853
69020749
COG
4273738
4510197
COM
689696
723865
CPV
492644
505241
DJI
840194
868136
DZA
35977451
37383899
EGY
82761244
86422240
ERI
3170437
nan
ETH
87639962
92726982
GAB
1624146
1749677
GHA
24779614
25996454
GIN
10192168
10652032
GMB
1793199
1905020
GNB
1522603
1604981
GNQ
943640
1031191
KEN
42030684
44343469
LBR
3891357
4135662
LBY
6197667
6285751
LSO
1995575
2014988
MAR
32343384
33241898
MDG
21151640
22346641
MLI
15049352
15979492
MOZ
23531567
24862673
MRT
3494200
3706555
MUS
1250400
1255882
MWI
14539609
15396010
NAM
2118877
2194777
NER
16464025
17795209
NGA
158503203
167228803
RWA
10039338
10549668
SDN
34545014
36193781
SEN
12678143
13401990
SLE
6415636
6712586
SOM
12043886
12715487
SSD
9508372
10113648
STP
180372
188394
SWZ
1064841
1079285
SYC
89770
88303
TCD
11952134
12784748
TGO
6421674
6773807
TUN
10635245
10846993
TZA
44346532
47053033
UGA
32428164
34558700
ZAF
51216967
52832659
ZMB
13605986
14465148
ZWE
12697728
13115149
Income groups
Topics
Series
Search series
Metadata of series
Import data
Function DataFrame
Help on function DataFrame in module wbgapi.data:
DataFrame(series, economy='all', time='all', index=None, columns=None, mrv=None, mrnev=None, skipBlanks=False, labels=False, skipAggs=False, numericTimeKeys=False, timeColumns=False, params={}, db=None, **dimensions)
Retrieve a 2-dimensional pandas dataframe.
Arguments:
series: a series identifier or list-like, e.g., SP.POP.TOTL
economy: an economy identifier or list-like, e.g., 'BRA' or ['USA', 'CAN', 'MEX']
time: a time identifier or list-like, e.g., 'YR2015' or range(2010,2020).
Both element keys and values are acceptable
index: name or list of dimensions for the DataFrame's index, e.g., 'economy'. If None then the function
will define the index based on your request. Note: to get a dataframe with no index
(i.e., 0-based integers) call `reset_index()` with on the return value of this function.
columns: name of the dimension for the DataFrame's columns, e.g., 'series'. If None then the function
will define columns based on your request.
mrv: return only the specified number of most recent values (same time period for all economies)
mrnev: return only the specified number of non-empty most recent values (time period varies)
skipBlanks: skip empty observations
labels: include the dimension name for rows
skipAggs: skip aggregates
numericTimeKeys: store the time object by value (e.g., 2014) instead of key ('YR2014') if value is numeric
timeColumns: add extra columns to show the time dimension for each series/economy
If 'auto' then the function will guess based on other parameters
params: extra query parameters to pass to the API
dimensions: extra dimensions, database specific (e.g., version)
Returns:
a pandas DataFrame
Examples:
# 5 years of population data (with economy names)
wbgapi.data.DataFrame('SP.POP.TOTL, time=range(2010,2020),labels=True)
# Most recent poverty and income data for LAC
wbgapi.data.DataFrame(['SI.POV.NAHC', 'NY.GDP.PCAP.CD'], economy=wb.region.members('LAC'),mrnev=1,timeColumns=True)
# Fetch most recent CO2 emissions for each country and merge its income group
wbgapi.data.DataFrame('EN.ATM.CO2E.PC',mrnev=1).join(wbgapi.economy.DataFrame()['incomeLevel'])
# Top 10 emitters per capita
wbgapi.data.DataFrame('EN.ATM.CO2E.PC',mrnev=1,labels=True).sort_values('EN.ATM.CO2E.PC',ascending=False).head(10)
Notes:
timeColumns currently defaults to False so that the default column composition is consistent. This may change to 'auto'
at some point, so that mrv behavior is more intuitive for data discovery
ZWE
Zimbabwe
12697728
ZMB
Zambia
13605986
YEM
Yemen, Rep.
23154854
PSE
West Bank and Gaza
3786161
VIR
Virgin Islands (U.S.)
108357
VNM
Vietnam
87967655
VEN
Venezuela, RB
28439942
VUT
Vanuatu
236216
UZB
Uzbekistan
28562400
URY
Uruguay
3359273
COL
Colombia
5334.556042
BOL
Bolivia
3133.099803
NIC
Nicaragua
1905.261152
PAN
Panama
12509.83529
SLV
El Salvador
3798.636521
ARG
Argentina
8579.017773
ECU
Ecuador
5600.389615
PER
Peru
6126.87454
MEX
Mexico
8329.271313
JAM
Jamaica
4664.530242
AFE
Africa Eastern and Southern
0.9335412011
AFW
Africa Western and Central
0.515544239
ARB
Arab World
4.438715965
CSS
Caribbean small states
5.017034408
CEB
Central Europe and the Baltics
6.597232486
EAR
Early-demographic dividend
2.27814572
EAS
East Asia & Pacific
6.333951297
EAP
East Asia & Pacific (excluding high income)
5.692966704
TEA
East Asia & Pacific (IDA & IBRD countries)
5.754705895
EMU
Euro area
6.454837567
QAT
Qatar
32.41563917
KWT
Kuwait
21.62272431
ARE
United Arab Emirates
20.7974984
BHR
Bahrain
19.59297584
BRN
Brunei Darussalam
16.64490862
PLW
Palau
16.19116744
CAN
Canada
15.49706457
AUS
Australia
15.47551649
LUX
Luxembourg
15.33020808
NAC
North America
15.27087956
Long and wide panel data
10
ABW
YR2010
11
ABW
YR2011
12
ABW
YR2012
13
ABW
YR2013
14
ABW
YR2014
15
ABW
YR2015
16
ABW
YR2016
17
ABW
YR2017
18
AFG
YR2002
19
AFG
YR2003
AGO
3289.409549
3389.196967
ALB
3860.804627
4299.546493
ARE
98365.15739
96724.06511
ARG
11618.79323
11226.87975
ARM
2658.344322
2995.908846
ATG
16843.12161
16173.32622
AUS
26343.0767
27439.82779
AUT
29376.01974
29702.79753
AZE
3385.512727
3772.943783
BDI
527.0808747
537.3594612
AUT
935.4604269
1031.815004
BEL
1273.691659
1350.197673
CYP
nan
nan
DEU
nan
nan
ESP
396.3922533
450.0532892
EST
nan
nan
FIN
1179.353011
1327.427224
FRA
1334.689512
1428.046001
GRC
520.3227443
590.7800548
IRL
685.6147124
739.2764064
AUT
935.4604269
1031.815004
BEL
1273.691659
1350.197673
ESP
396.3922533
450.0532892
FIN
1179.353011
1327.427224
FRA
1334.689512
1428.046001
GRC
520.3227443
590.7800548
IRL
685.6147124
739.2764064
ITA
804.4926233
887.3367446
LUX
2242.015817
2222.366366
NLD
1068.784587
1159.392357
DEU
6.198531223
10.15021111
ESP
15.61372617
14.60139232
FRA
12.96787647
9.860646697
GBR
2.663105175
4.283481612
USA
8.205996942
8.578465534
Countries and regions
0
ABW
Aruba
1
AFG
Afghanistan
2
AGO
Angola
3
ALB
Albania
4
AND
Andorra
5
ARE
United Arab Emirates
6
ARG
Argentina
7
ARM
Armenia
8
ASM
American Samoa
9
ATG
Antigua and Barbuda
Merge datasets
0
ABW
YR2000
1
ABW
YR2001
2
ABW
YR2002
3
ABW
YR2003
4
ABW
YR2004
5
ABW
YR2005
6
ABW
YR2006
7
ABW
YR2007
8
ABW
YR2008
9
ABW
YR2009
Visualize data
Bar plots
Line plots
0
2000
6.198531223
1
2005
10.15021111
2
2010
16.72707367
3
2015
29.23177012
IND
India
2578.59153
BTN
Bhutan
4061.499026
AFG
Afghanistan
nan
PAK
Pakistan
3245.378342
MDV
Maldives
13358.06556
NPL
Nepal
2077.652056
LKA
Sri Lanka
5949.970029
BGD
Bangladesh
1937.729192
0
AFG
YR2000
1
AFG
YR2001
2
AFG
YR2002
3
AFG
YR2003
4
AFG
YR2004
5
AFG
YR2005
6
AFG
YR2006
7
AFG
YR2007
8
AFG
YR2008
9
AFG
YR2009
Scatter plots
0
ABW
YR2017
1
AFG
YR2017
2
AFG
YR2018
3
AGO
YR2017
4
AGO
YR2018
5
ALB
YR2017
6
ALB
YR2018
7
ARE
YR2017
8
ARE
YR2018
9
ARG
YR2017
Maps
Cross-country inequality
AND
35391.0736
35159.46658
ARG
9243.256579
9613.676881
AUS
26894.50648
27040.51029
AUT
18101.99195
18943.18115
BDI
352.6487174
357.107685
BEL
17849.49471
18527.14874
BEN
758.3926365
730.9189297
BFA
276.4799815
275.5480694
BGD
512.1211627
474.4632052
BHS
28557.29298
28267.75498
YR1970
1.61
0.67
YR1971
1.61
0.67
YR1972
1.6
0.67
YR1973
1.6
0.67
YR1974
1.6
0.67
YR1975
1.59
0.66
YR1976
1.59
0.66
YR1977
1.6
0.66
YR1978
1.6
0.66
YR1979
1.59
0.66