-
Notifications
You must be signed in to change notification settings - Fork 12
/
readme.py
75 lines (56 loc) · 1.37 KB
/
readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
from weo import download, WEO
path, url = download(2022, 1)
# weo_2022_1.csv 18.8Mb
# Downloaded 2022-Apr WEO dataset
df_cpi = WEO(path).inflation()
print(df_cpi.USA.tail(8))
# USA
# 2020 1.549
# 2021 7.426
# 2022 5.329
# 2023 2.337
# 2024 2.096
# 2025 1.970
# 2026 1.983
# 2027 2.017
import weo
weo.download(year=2020, release="Oct", filename="weo.csv")
import pathlib
import weo
# create folder
pathlib.Path("weo_data").mkdir(parents=False, exist_ok=True)
# download all releases
for year, release in weo.all_releases():
weo.download(year, release, directory="weo_data")
from weo import WEO
w = WEO("weo.csv")
# variable listing
w.variables()
# units
w.units()
w.units("Gross domestic product, current prices")
# variable codes
w.codes
w.from_code("LUR")
# countries
w.countries("United") # Dataframe with United Arab Emirates, United Kingdom
# and United States
w.iso_code3("Netherlands") # 'NLD'
w.get("General government gross debt", "Percent of GDP")
w.getc("NGDP_RPCH")
w.country("DEU")
w.fix_year(1994)
(
w.gdp_usd(2024)
.dropna()
.sort_values()
.tail(12)
.plot.barh(title="GDP by country, USD billion (2024)")
)
w.gdp_pc_usd(start_year=2000, end_year=2020)
from dbnomics import fetch_series_by_api_link
ts1 = fetch_series_by_api_link(
"https://api.db.nomics.world/v22/"
"series/IMF/WEO:latest/DEU.PCPI"
"?observations=1"
)