oda-data 2.0.0__tar.gz → 2.0.0b2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {oda_data-2.0.0 → oda_data-2.0.0b2}/PKG-INFO +53 -52
- {oda_data-2.0.0 → oda_data-2.0.0b2}/README.md +51 -50
- oda_data-2.0.0b2/oda_data/__init__.py +37 -0
- oda_data-2.0.0b2/oda_data/api/constants.py +80 -0
- oda_data-2.0.0/oda_data/api/oecd.py → oda_data-2.0.0b2/oda_data/api/main.py +25 -44
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/api/sources.py +171 -31
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/clean_data/channels.py +10 -10
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/clean_data/common.py +8 -8
- oda_data-2.0.0b2/oda_data/clean_data/dtypes.py +167 -0
- oda_data-2.0.0b2/oda_data/clean_data/schema.py +265 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/config.py +1 -2
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/crs/common.py +12 -21
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/crs/crs_functions.py +22 -22
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/crs/oecd.py +4 -6
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/crs/one.py +2 -2
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac1/common.py +4 -4
- oda_data-2.0.0b2/oda_data/indicators/dac1/dac1_functions.py +13 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac1/oecd.py +2 -2
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac1/one.py +3 -4
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac2a/common.py +2 -2
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac2a/oecd.py +2 -2
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac2a/one.py +2 -2
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/research/sector_imputations.py +62 -39
- oda_data-2.0.0/oda_data/settings/provider_groupings.json → oda_data-2.0.0b2/oda_data/settings/donor_groupings.json +1 -2
- oda_data-2.0.0b2/oda_data/tools/README.md +5 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/tools/compatibility.py +3 -3
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/tools/groupings.py +4 -4
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/tools/sector_lists.py +4 -4
- {oda_data-2.0.0 → oda_data-2.0.0b2}/pyproject.toml +11 -7
- oda_data-2.0.0/oda_data/__init__.py +0 -46
- oda_data-2.0.0/oda_data/api/constants.py +0 -167
- oda_data-2.0.0/oda_data/clean_data/dtypes.py +0 -167
- oda_data-2.0.0/oda_data/clean_data/schema.py +0 -279
- oda_data-2.0.0/oda_data/indicators/dac1/dac1_functions.py +0 -65
- oda_data-2.0.0/oda_data/indicators/research/eu.py +0 -146
- oda_data-2.0.0/oda_data/indicators/research/policy_markers.py +0 -120
- oda_data-2.0.0/oda_data/tools/gni.py +0 -94
- oda_data-2.0.0/oda_data/tools/names/__init__.py +0 -0
- oda_data-2.0.0/oda_data/tools/names/add.py +0 -54
- oda_data-2.0.0/oda_data/tools/names/create_mapping.py +0 -175
- oda_data-2.0.0/oda_data/tools/names/crs_names.json +0 -1186
- oda_data-2.0.0/oda_data/tools/names/dac1_names.json +0 -216
- oda_data-2.0.0/oda_data/tools/names/dac2a_names.json +0 -478
- {oda_data-2.0.0 → oda_data-2.0.0b2}/LICENSE +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/.raw_data/README.md +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/api/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/api/representations.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/clean_data/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/clean_data/crs_channel_mapping.csv +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/clean_data/validation.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/common.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/crs/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/crs/crs_indicators.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac1/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac1/dac1_indicators.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac2a/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac2a/dac2a_functions.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/dac2a/dac2a_indicators.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/indicator.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/indicators/research/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/logger.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/crs_flow_types.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/crs_modalities.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/crs_policy_markers.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/crs_purpose.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/crs_type_of_finance.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/dac1_aid_flow_types.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/dac2a_aid_type.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/flow_types.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/indicators.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/key_columns.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/recipient_groupings.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/settings/v1_indicators_mapping.json +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/tools/__init__.py +0 -0
- {oda_data-2.0.0 → oda_data-2.0.0b2}/oda_data/tools/cache.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: oda_data
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.0b2
|
|
4
4
|
Summary: A python package to work with Official Development Assistance data from the OECD DAC.
|
|
5
5
|
Author: Jorge Rivera
|
|
6
6
|
Author-email: jorge.rivera@one.org
|
|
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
13
13
|
Provides-Extra: dev
|
|
14
14
|
Requires-Dist: black (>=24) ; extra == "dev"
|
|
15
15
|
Requires-Dist: cachetools (>=5.5.1,<6.0.0)
|
|
16
|
-
Requires-Dist: oda-reader (>=1
|
|
16
|
+
Requires-Dist: oda-reader (>=1)
|
|
17
17
|
Requires-Dist: pandas (>=2)
|
|
18
18
|
Requires-Dist: pyarrow (>=14,<20)
|
|
19
19
|
Requires-Dist: pydeflate (>=2.0.1)
|
|
@@ -27,14 +27,13 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
[](https://pypi.org/project/oda_data/)
|
|
29
29
|
[](https://pypi.org/project/oda_data/)
|
|
30
|
+
[](https://codecov.io/gh/ONEcampaign/oda_data_package)
|
|
30
31
|
[](https://github.com/psf/black)
|
|
31
32
|
|
|
32
33
|
# The ODA Data Package
|
|
33
34
|
This is a Python package designed for accessing, processing, and analyzing Official Development Assistance (ODA) data from OECD DAC. With an intuitive API, it simplifies common tasks like retrieving ODA indicators, converting currencies, filtering data, and handling bulk downloads.
|
|
34
35
|
|
|
35
|
-
**Note:
|
|
36
|
-
will not work. The previous 1.5.x version remains available on PyPI and we will continue to support it at least until
|
|
37
|
-
August 2025.**
|
|
36
|
+
**Note: You are currently looking at a pre-release version of the package. We are aiming for a stable release mid-April 2025. The documentation is still incomplete, and features and APIs may change before release.**
|
|
38
37
|
|
|
39
38
|
Interacting with the DAC databases can be a complex task. There are many databases, tables, and web interfaces which
|
|
40
39
|
can be used to get the data you need. This means that getting the right ODA data can require expert knowledge not only
|
|
@@ -59,7 +58,7 @@ The package is compatible with Python 3.10 and above.
|
|
|
59
58
|
|
|
60
59
|
## Basic usage
|
|
61
60
|
|
|
62
|
-
Most users can get the data they need by using the `
|
|
61
|
+
Most users can get the data they need by using the `Indicators` class.
|
|
63
62
|
|
|
64
63
|
An object of this class can handle:
|
|
65
64
|
- getting data for specific indicators (one or more)
|
|
@@ -71,15 +70,14 @@ data for all providers, for all recipients (if applicable), as net disbursements
|
|
|
71
70
|
using the OECD data-explorer API.
|
|
72
71
|
|
|
73
72
|
In the example below, we get all data for Total ODA (net disbursements), for 2012 to 2022.
|
|
74
|
-
|
|
75
73
|
```python
|
|
76
|
-
from oda_data import
|
|
74
|
+
from oda_data import Indicators, set_data_path
|
|
77
75
|
|
|
78
|
-
# set the path to the folder where the
|
|
76
|
+
# set the path to the folder where the data should be stored
|
|
79
77
|
set_data_path("path/to/data/folder")
|
|
80
78
|
|
|
81
79
|
# create object, specifying key details of the desired output
|
|
82
|
-
indicator =
|
|
80
|
+
indicator = Indicators( years=range(2012,2023))
|
|
83
81
|
|
|
84
82
|
# Get the desired indicator
|
|
85
83
|
data = indicator.get_indicators("DAC1.10.1010")
|
|
@@ -88,100 +86,100 @@ data = indicator.get_indicators("DAC1.10.1010")
|
|
|
88
86
|
Here's an example to get Bilateral ODA for France and the US, for 2020 and 2021. The data will be in grant equivalents, in constant 2019 Euros.
|
|
89
87
|
|
|
90
88
|
```python
|
|
91
|
-
from oda_data import
|
|
89
|
+
from oda_data import Indicators, set_data_path
|
|
92
90
|
|
|
93
91
|
# set the path to the folder where the data should be stored
|
|
94
92
|
set_data_path("path/to/data/folder")
|
|
95
93
|
|
|
96
94
|
# create object, specifying key details of the desired output
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
indicator = Indicators(
|
|
96
|
+
years=[2020, 2021],
|
|
97
|
+
providers=[4, 302], # Example provider codes
|
|
98
|
+
measure="grant_equivalent", # Options: "commitment", "grant_equivalent", etc.
|
|
99
|
+
currency="EUR", # Default is USD; others include EUR, GBP, CAD, LCU
|
|
100
|
+
base_year=2019, # Adjust data to constant prices of the specified year
|
|
103
101
|
)
|
|
104
102
|
|
|
105
103
|
# Get the desired indicator
|
|
106
|
-
data =
|
|
104
|
+
data = indicator.get_indicators("DAC1.10.11015")
|
|
107
105
|
```
|
|
108
106
|
|
|
109
107
|
If you intend to download many indicators, we recommend using the Bulk download file instead. The OECD data-explorer
|
|
110
108
|
API has pretty low usage limits, and you could get a temporary block if you make too many repeated calls. While downloading a particular bulk file may time a few minutes, subsequently getting indicator data is much faster.
|
|
111
109
|
|
|
112
110
|
```python
|
|
113
|
-
from oda_data import
|
|
111
|
+
from oda_data import Indicators, set_data_path
|
|
114
112
|
|
|
115
113
|
# set the path to the folder where the data should be stored
|
|
116
114
|
set_data_path("path/to/data/folder")
|
|
117
115
|
|
|
118
116
|
# define a list of indicators to get
|
|
119
|
-
research_indicators = ["DAC1.10.1100",
|
|
117
|
+
research_indicators = ["DAC1.10.1100","DAC1.10.1410","DAC1.10.2102","DAC1.10.1500"]
|
|
120
118
|
|
|
121
119
|
# create object, specifying key details of the desired output
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
indicator = Indicators(
|
|
121
|
+
years=[2019, 2020, 2021],
|
|
122
|
+
measure="net_disbursement", # Options: "commitment", "grant_equivalent", etc.
|
|
123
|
+
currency="LCU", # To get the data in providers' own currencies
|
|
124
|
+
use_bulk_download=True
|
|
127
125
|
)
|
|
128
126
|
|
|
129
127
|
# Get the desired indicators
|
|
130
|
-
data =
|
|
128
|
+
data = indicator.get_indicators(research_indicators)
|
|
131
129
|
```
|
|
132
130
|
|
|
133
|
-
###
|
|
131
|
+
### Indicators
|
|
134
132
|
|
|
135
133
|
Over three thousand indicators are currently supported. They are mostly produced by filtering (and sometimes aggregating) data from the different DAC Tables and databases.
|
|
136
134
|
|
|
137
135
|
You can get a dictionary with all supported indicators, with their code, name, description and source by using the `.available_indicators()` method:
|
|
138
136
|
|
|
139
137
|
```python
|
|
140
|
-
from oda_data import
|
|
138
|
+
from oda_data import Indicators
|
|
141
139
|
|
|
142
|
-
all_indicators =
|
|
140
|
+
all_indicators = Indicators.available_indicators()
|
|
143
141
|
```
|
|
144
142
|
|
|
145
143
|
Alternatively, you can export the indicators to a CSV by using the `.export_available_indicators()` method.
|
|
146
144
|
|
|
147
145
|
```python
|
|
148
|
-
from oda_data import
|
|
146
|
+
from oda_data import Indicators
|
|
149
147
|
|
|
150
|
-
|
|
148
|
+
Indicators.export_available_indicators(export_folder="path/to/folder/")
|
|
151
149
|
```
|
|
152
150
|
|
|
153
151
|
### Providers
|
|
154
152
|
You can get a dictionary with all available providers, with their code and name, by using the `.available_providers()` method:
|
|
155
153
|
|
|
156
154
|
```python
|
|
157
|
-
from oda_data import
|
|
155
|
+
from oda_data import Indicators
|
|
158
156
|
|
|
159
|
-
providers =
|
|
157
|
+
providers = Indicators.available_providers()
|
|
160
158
|
```
|
|
161
159
|
|
|
162
160
|
### Recipients
|
|
163
161
|
You can get a dictionary with all available recipients, with their code and name, by using the `.available_recipients()` method:
|
|
164
162
|
|
|
165
163
|
```python
|
|
166
|
-
from oda_data import
|
|
164
|
+
from oda_data import Indicators
|
|
167
165
|
|
|
168
|
-
recipients =
|
|
166
|
+
recipients = Indicators.available_recipients()
|
|
169
167
|
```
|
|
170
168
|
|
|
171
169
|
### Currencies
|
|
172
170
|
You can get a dictionary with all available currencies, with their code and name, by using the `.available_currencies()` method:
|
|
173
171
|
|
|
174
172
|
```python
|
|
175
|
-
from oda_data import
|
|
173
|
+
from oda_data import Indicators
|
|
176
174
|
|
|
177
|
-
currencies =
|
|
175
|
+
currencies = Indicators.available_currencies()
|
|
178
176
|
```
|
|
179
177
|
|
|
180
178
|
## Accessing the data
|
|
181
179
|
For more advanced users, you can use this package to get and work with different tables and databases from the OECD DAC.
|
|
182
180
|
|
|
183
181
|
### DAC 1
|
|
184
|
-
The `
|
|
182
|
+
The `Dac1Data` class can retrieve and return DAC 1 data.
|
|
185
183
|
|
|
186
184
|
You can optionally specify:
|
|
187
185
|
- years: to filter the data for specific years
|
|
@@ -195,13 +193,13 @@ After instantiating the object, you can call:
|
|
|
195
193
|
- `read`: to read data as stored in the specified folder. If the data is not available, it will be downloaded.
|
|
196
194
|
|
|
197
195
|
```python
|
|
198
|
-
from oda_data import
|
|
196
|
+
from oda_data import Dac1Data, set_data_path
|
|
199
197
|
|
|
200
198
|
# set the path to the folder where the data should be stored
|
|
201
199
|
set_data_path("path/to/data/folder")
|
|
202
200
|
|
|
203
201
|
# instantiate a DAC1Data object
|
|
204
|
-
dac1 =
|
|
202
|
+
dac1 = Dac1Data()
|
|
205
203
|
|
|
206
204
|
# Perform a bulk download
|
|
207
205
|
dac1.download(bulk=True)
|
|
@@ -214,14 +212,15 @@ Use cases can be quite elaborate. For example, here we will download data for Fr
|
|
|
214
212
|
|
|
215
213
|
When reading, we will also filter to get only current prices, and to only read a few columns.
|
|
216
214
|
|
|
215
|
+
|
|
217
216
|
```python
|
|
218
|
-
from oda_data import
|
|
217
|
+
from oda_data import Dac1Data, set_data_path
|
|
219
218
|
|
|
220
219
|
# set the path to the folder where the data should be stored
|
|
221
220
|
set_data_path("path/to/data/folder")
|
|
222
221
|
|
|
223
222
|
# instantiate a DAC1Data object
|
|
224
|
-
dac1 =
|
|
223
|
+
dac1 = Dac1Data(years=2022, providers=4, indicators=1010)
|
|
225
224
|
|
|
226
225
|
# Get the data by calling on read. It will be downloaded since it isn't already available.
|
|
227
226
|
data = dac1.read(
|
|
@@ -232,7 +231,7 @@ data = dac1.read(
|
|
|
232
231
|
|
|
233
232
|
|
|
234
233
|
### DAC 2A
|
|
235
|
-
The `
|
|
234
|
+
The `Dac2aData` class can retrieve and return DAC2a data.
|
|
236
235
|
|
|
237
236
|
You can optionally specify:
|
|
238
237
|
- years: to filter the data for specific years
|
|
@@ -247,13 +246,13 @@ After instantiating the object, you can call:
|
|
|
247
246
|
- `read`: to read data as stored in the specified folder. If the data is not available, it will be downloaded.
|
|
248
247
|
|
|
249
248
|
```python
|
|
250
|
-
from oda_data import
|
|
249
|
+
from oda_data import Dac2aData, set_data_path
|
|
251
250
|
|
|
252
251
|
# set the path to the folder where the data should be stored
|
|
253
252
|
set_data_path("path/to/data/folder")
|
|
254
253
|
|
|
255
254
|
# instantiate a DAC1Data object
|
|
256
|
-
dac2a =
|
|
255
|
+
dac2a = Dac2aData()
|
|
257
256
|
|
|
258
257
|
# Perform a bulk download
|
|
259
258
|
dac2a.download(bulk=True)
|
|
@@ -267,14 +266,15 @@ multilateral aid.
|
|
|
267
266
|
|
|
268
267
|
When reading, we will also filter to get only current prices, and to only read a few columns.
|
|
269
268
|
|
|
269
|
+
|
|
270
270
|
```python
|
|
271
|
-
from oda_data import
|
|
271
|
+
from oda_data import Dac2aData, set_data_path
|
|
272
272
|
|
|
273
273
|
# set the path to the folder where the data should be stored
|
|
274
274
|
set_data_path("path/to/data/folder")
|
|
275
275
|
|
|
276
276
|
# instantiate a DAC2aData object
|
|
277
|
-
dac2a =
|
|
277
|
+
dac2a = Dac2aData(years=2022, providers=4, recipients=283, indicators=106)
|
|
278
278
|
|
|
279
279
|
# Get the data by calling on read. It will be downloaded since it isn't already available.
|
|
280
280
|
data = dac2a.read(
|
|
@@ -292,7 +292,7 @@ data = dac2a.read(
|
|
|
292
292
|
```
|
|
293
293
|
|
|
294
294
|
### CRS
|
|
295
|
-
The `
|
|
295
|
+
The `CrsData` class can retrieve and return CRS data.
|
|
296
296
|
|
|
297
297
|
You can optionally specify:
|
|
298
298
|
- years: to filter the data for specific years
|
|
@@ -305,21 +305,22 @@ You can refer to the examples above for DAC1 and DAC2a to understand the usage o
|
|
|
305
305
|
**Note**: given the speed and rate-limiting of the dac-explorer APIs, it's recommended to always use the
|
|
306
306
|
bulk option when using the CRS class.
|
|
307
307
|
|
|
308
|
+
|
|
308
309
|
```python
|
|
309
|
-
from oda_data import
|
|
310
|
+
from oda_data import CrsData, set_data_path
|
|
310
311
|
|
|
311
312
|
# set the path to the folder where the data should be stored
|
|
312
313
|
set_data_path("path/to/data/folder")
|
|
313
314
|
|
|
314
|
-
# instantiate a
|
|
315
|
-
crs =
|
|
315
|
+
# instantiate a CrsData object
|
|
316
|
+
crs = CrsData(years=range(2010,2024))
|
|
316
317
|
|
|
317
318
|
# Get the data by calling on read. It will be downloaded since it isn't already available.
|
|
318
319
|
data = crs.read(using_bulk_download=True)
|
|
319
320
|
```
|
|
320
321
|
|
|
321
322
|
|
|
322
|
-
###
|
|
323
|
+
### CRS
|
|
323
324
|
The `MultiSystemData` class can retrieve and return Providers Total Use of the Multilateral System data.
|
|
324
325
|
|
|
325
326
|
You can optionally specify:
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
[](https://pypi.org/project/oda_data/)
|
|
2
2
|
[](https://pypi.org/project/oda_data/)
|
|
3
|
+
[](https://codecov.io/gh/ONEcampaign/oda_data_package)
|
|
3
4
|
[](https://github.com/psf/black)
|
|
4
5
|
|
|
5
6
|
# The ODA Data Package
|
|
6
7
|
This is a Python package designed for accessing, processing, and analyzing Official Development Assistance (ODA) data from OECD DAC. With an intuitive API, it simplifies common tasks like retrieving ODA indicators, converting currencies, filtering data, and handling bulk downloads.
|
|
7
8
|
|
|
8
|
-
**Note:
|
|
9
|
-
will not work. The previous 1.5.x version remains available on PyPI and we will continue to support it at least until
|
|
10
|
-
August 2025.**
|
|
9
|
+
**Note: You are currently looking at a pre-release version of the package. We are aiming for a stable release mid-April 2025. The documentation is still incomplete, and features and APIs may change before release.**
|
|
11
10
|
|
|
12
11
|
Interacting with the DAC databases can be a complex task. There are many databases, tables, and web interfaces which
|
|
13
12
|
can be used to get the data you need. This means that getting the right ODA data can require expert knowledge not only
|
|
@@ -32,7 +31,7 @@ The package is compatible with Python 3.10 and above.
|
|
|
32
31
|
|
|
33
32
|
## Basic usage
|
|
34
33
|
|
|
35
|
-
Most users can get the data they need by using the `
|
|
34
|
+
Most users can get the data they need by using the `Indicators` class.
|
|
36
35
|
|
|
37
36
|
An object of this class can handle:
|
|
38
37
|
- getting data for specific indicators (one or more)
|
|
@@ -44,15 +43,14 @@ data for all providers, for all recipients (if applicable), as net disbursements
|
|
|
44
43
|
using the OECD data-explorer API.
|
|
45
44
|
|
|
46
45
|
In the example below, we get all data for Total ODA (net disbursements), for 2012 to 2022.
|
|
47
|
-
|
|
48
46
|
```python
|
|
49
|
-
from oda_data import
|
|
47
|
+
from oda_data import Indicators, set_data_path
|
|
50
48
|
|
|
51
|
-
# set the path to the folder where the
|
|
49
|
+
# set the path to the folder where the data should be stored
|
|
52
50
|
set_data_path("path/to/data/folder")
|
|
53
51
|
|
|
54
52
|
# create object, specifying key details of the desired output
|
|
55
|
-
indicator =
|
|
53
|
+
indicator = Indicators( years=range(2012,2023))
|
|
56
54
|
|
|
57
55
|
# Get the desired indicator
|
|
58
56
|
data = indicator.get_indicators("DAC1.10.1010")
|
|
@@ -61,100 +59,100 @@ data = indicator.get_indicators("DAC1.10.1010")
|
|
|
61
59
|
Here's an example to get Bilateral ODA for France and the US, for 2020 and 2021. The data will be in grant equivalents, in constant 2019 Euros.
|
|
62
60
|
|
|
63
61
|
```python
|
|
64
|
-
from oda_data import
|
|
62
|
+
from oda_data import Indicators, set_data_path
|
|
65
63
|
|
|
66
64
|
# set the path to the folder where the data should be stored
|
|
67
65
|
set_data_path("path/to/data/folder")
|
|
68
66
|
|
|
69
67
|
# create object, specifying key details of the desired output
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
indicator = Indicators(
|
|
69
|
+
years=[2020, 2021],
|
|
70
|
+
providers=[4, 302], # Example provider codes
|
|
71
|
+
measure="grant_equivalent", # Options: "commitment", "grant_equivalent", etc.
|
|
72
|
+
currency="EUR", # Default is USD; others include EUR, GBP, CAD, LCU
|
|
73
|
+
base_year=2019, # Adjust data to constant prices of the specified year
|
|
76
74
|
)
|
|
77
75
|
|
|
78
76
|
# Get the desired indicator
|
|
79
|
-
data =
|
|
77
|
+
data = indicator.get_indicators("DAC1.10.11015")
|
|
80
78
|
```
|
|
81
79
|
|
|
82
80
|
If you intend to download many indicators, we recommend using the Bulk download file instead. The OECD data-explorer
|
|
83
81
|
API has pretty low usage limits, and you could get a temporary block if you make too many repeated calls. While downloading a particular bulk file may time a few minutes, subsequently getting indicator data is much faster.
|
|
84
82
|
|
|
85
83
|
```python
|
|
86
|
-
from oda_data import
|
|
84
|
+
from oda_data import Indicators, set_data_path
|
|
87
85
|
|
|
88
86
|
# set the path to the folder where the data should be stored
|
|
89
87
|
set_data_path("path/to/data/folder")
|
|
90
88
|
|
|
91
89
|
# define a list of indicators to get
|
|
92
|
-
research_indicators = ["DAC1.10.1100",
|
|
90
|
+
research_indicators = ["DAC1.10.1100","DAC1.10.1410","DAC1.10.2102","DAC1.10.1500"]
|
|
93
91
|
|
|
94
92
|
# create object, specifying key details of the desired output
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
indicator = Indicators(
|
|
94
|
+
years=[2019, 2020, 2021],
|
|
95
|
+
measure="net_disbursement", # Options: "commitment", "grant_equivalent", etc.
|
|
96
|
+
currency="LCU", # To get the data in providers' own currencies
|
|
97
|
+
use_bulk_download=True
|
|
100
98
|
)
|
|
101
99
|
|
|
102
100
|
# Get the desired indicators
|
|
103
|
-
data =
|
|
101
|
+
data = indicator.get_indicators(research_indicators)
|
|
104
102
|
```
|
|
105
103
|
|
|
106
|
-
###
|
|
104
|
+
### Indicators
|
|
107
105
|
|
|
108
106
|
Over three thousand indicators are currently supported. They are mostly produced by filtering (and sometimes aggregating) data from the different DAC Tables and databases.
|
|
109
107
|
|
|
110
108
|
You can get a dictionary with all supported indicators, with their code, name, description and source by using the `.available_indicators()` method:
|
|
111
109
|
|
|
112
110
|
```python
|
|
113
|
-
from oda_data import
|
|
111
|
+
from oda_data import Indicators
|
|
114
112
|
|
|
115
|
-
all_indicators =
|
|
113
|
+
all_indicators = Indicators.available_indicators()
|
|
116
114
|
```
|
|
117
115
|
|
|
118
116
|
Alternatively, you can export the indicators to a CSV by using the `.export_available_indicators()` method.
|
|
119
117
|
|
|
120
118
|
```python
|
|
121
|
-
from oda_data import
|
|
119
|
+
from oda_data import Indicators
|
|
122
120
|
|
|
123
|
-
|
|
121
|
+
Indicators.export_available_indicators(export_folder="path/to/folder/")
|
|
124
122
|
```
|
|
125
123
|
|
|
126
124
|
### Providers
|
|
127
125
|
You can get a dictionary with all available providers, with their code and name, by using the `.available_providers()` method:
|
|
128
126
|
|
|
129
127
|
```python
|
|
130
|
-
from oda_data import
|
|
128
|
+
from oda_data import Indicators
|
|
131
129
|
|
|
132
|
-
providers =
|
|
130
|
+
providers = Indicators.available_providers()
|
|
133
131
|
```
|
|
134
132
|
|
|
135
133
|
### Recipients
|
|
136
134
|
You can get a dictionary with all available recipients, with their code and name, by using the `.available_recipients()` method:
|
|
137
135
|
|
|
138
136
|
```python
|
|
139
|
-
from oda_data import
|
|
137
|
+
from oda_data import Indicators
|
|
140
138
|
|
|
141
|
-
recipients =
|
|
139
|
+
recipients = Indicators.available_recipients()
|
|
142
140
|
```
|
|
143
141
|
|
|
144
142
|
### Currencies
|
|
145
143
|
You can get a dictionary with all available currencies, with their code and name, by using the `.available_currencies()` method:
|
|
146
144
|
|
|
147
145
|
```python
|
|
148
|
-
from oda_data import
|
|
146
|
+
from oda_data import Indicators
|
|
149
147
|
|
|
150
|
-
currencies =
|
|
148
|
+
currencies = Indicators.available_currencies()
|
|
151
149
|
```
|
|
152
150
|
|
|
153
151
|
## Accessing the data
|
|
154
152
|
For more advanced users, you can use this package to get and work with different tables and databases from the OECD DAC.
|
|
155
153
|
|
|
156
154
|
### DAC 1
|
|
157
|
-
The `
|
|
155
|
+
The `Dac1Data` class can retrieve and return DAC 1 data.
|
|
158
156
|
|
|
159
157
|
You can optionally specify:
|
|
160
158
|
- years: to filter the data for specific years
|
|
@@ -168,13 +166,13 @@ After instantiating the object, you can call:
|
|
|
168
166
|
- `read`: to read data as stored in the specified folder. If the data is not available, it will be downloaded.
|
|
169
167
|
|
|
170
168
|
```python
|
|
171
|
-
from oda_data import
|
|
169
|
+
from oda_data import Dac1Data, set_data_path
|
|
172
170
|
|
|
173
171
|
# set the path to the folder where the data should be stored
|
|
174
172
|
set_data_path("path/to/data/folder")
|
|
175
173
|
|
|
176
174
|
# instantiate a DAC1Data object
|
|
177
|
-
dac1 =
|
|
175
|
+
dac1 = Dac1Data()
|
|
178
176
|
|
|
179
177
|
# Perform a bulk download
|
|
180
178
|
dac1.download(bulk=True)
|
|
@@ -187,14 +185,15 @@ Use cases can be quite elaborate. For example, here we will download data for Fr
|
|
|
187
185
|
|
|
188
186
|
When reading, we will also filter to get only current prices, and to only read a few columns.
|
|
189
187
|
|
|
188
|
+
|
|
190
189
|
```python
|
|
191
|
-
from oda_data import
|
|
190
|
+
from oda_data import Dac1Data, set_data_path
|
|
192
191
|
|
|
193
192
|
# set the path to the folder where the data should be stored
|
|
194
193
|
set_data_path("path/to/data/folder")
|
|
195
194
|
|
|
196
195
|
# instantiate a DAC1Data object
|
|
197
|
-
dac1 =
|
|
196
|
+
dac1 = Dac1Data(years=2022, providers=4, indicators=1010)
|
|
198
197
|
|
|
199
198
|
# Get the data by calling on read. It will be downloaded since it isn't already available.
|
|
200
199
|
data = dac1.read(
|
|
@@ -205,7 +204,7 @@ data = dac1.read(
|
|
|
205
204
|
|
|
206
205
|
|
|
207
206
|
### DAC 2A
|
|
208
|
-
The `
|
|
207
|
+
The `Dac2aData` class can retrieve and return DAC2a data.
|
|
209
208
|
|
|
210
209
|
You can optionally specify:
|
|
211
210
|
- years: to filter the data for specific years
|
|
@@ -220,13 +219,13 @@ After instantiating the object, you can call:
|
|
|
220
219
|
- `read`: to read data as stored in the specified folder. If the data is not available, it will be downloaded.
|
|
221
220
|
|
|
222
221
|
```python
|
|
223
|
-
from oda_data import
|
|
222
|
+
from oda_data import Dac2aData, set_data_path
|
|
224
223
|
|
|
225
224
|
# set the path to the folder where the data should be stored
|
|
226
225
|
set_data_path("path/to/data/folder")
|
|
227
226
|
|
|
228
227
|
# instantiate a DAC1Data object
|
|
229
|
-
dac2a =
|
|
228
|
+
dac2a = Dac2aData()
|
|
230
229
|
|
|
231
230
|
# Perform a bulk download
|
|
232
231
|
dac2a.download(bulk=True)
|
|
@@ -240,14 +239,15 @@ multilateral aid.
|
|
|
240
239
|
|
|
241
240
|
When reading, we will also filter to get only current prices, and to only read a few columns.
|
|
242
241
|
|
|
242
|
+
|
|
243
243
|
```python
|
|
244
|
-
from oda_data import
|
|
244
|
+
from oda_data import Dac2aData, set_data_path
|
|
245
245
|
|
|
246
246
|
# set the path to the folder where the data should be stored
|
|
247
247
|
set_data_path("path/to/data/folder")
|
|
248
248
|
|
|
249
249
|
# instantiate a DAC2aData object
|
|
250
|
-
dac2a =
|
|
250
|
+
dac2a = Dac2aData(years=2022, providers=4, recipients=283, indicators=106)
|
|
251
251
|
|
|
252
252
|
# Get the data by calling on read. It will be downloaded since it isn't already available.
|
|
253
253
|
data = dac2a.read(
|
|
@@ -265,7 +265,7 @@ data = dac2a.read(
|
|
|
265
265
|
```
|
|
266
266
|
|
|
267
267
|
### CRS
|
|
268
|
-
The `
|
|
268
|
+
The `CrsData` class can retrieve and return CRS data.
|
|
269
269
|
|
|
270
270
|
You can optionally specify:
|
|
271
271
|
- years: to filter the data for specific years
|
|
@@ -278,21 +278,22 @@ You can refer to the examples above for DAC1 and DAC2a to understand the usage o
|
|
|
278
278
|
**Note**: given the speed and rate-limiting of the dac-explorer APIs, it's recommended to always use the
|
|
279
279
|
bulk option when using the CRS class.
|
|
280
280
|
|
|
281
|
+
|
|
281
282
|
```python
|
|
282
|
-
from oda_data import
|
|
283
|
+
from oda_data import CrsData, set_data_path
|
|
283
284
|
|
|
284
285
|
# set the path to the folder where the data should be stored
|
|
285
286
|
set_data_path("path/to/data/folder")
|
|
286
287
|
|
|
287
|
-
# instantiate a
|
|
288
|
-
crs =
|
|
288
|
+
# instantiate a CrsData object
|
|
289
|
+
crs = CrsData(years=range(2010,2024))
|
|
289
290
|
|
|
290
291
|
# Get the data by calling on read. It will be downloaded since it isn't already available.
|
|
291
292
|
data = crs.read(using_bulk_download=True)
|
|
292
293
|
```
|
|
293
294
|
|
|
294
295
|
|
|
295
|
-
###
|
|
296
|
+
### CRS
|
|
296
297
|
The `MultiSystemData` class can retrieve and return Providers Total Use of the Multilateral System data.
|
|
297
298
|
|
|
298
299
|
You can optionally specify:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from importlib.metadata import version
|
|
2
|
+
|
|
3
|
+
__version__ = version("oda_data")
|
|
4
|
+
|
|
5
|
+
from oda_data import tools
|
|
6
|
+
from oda_data.api.main import Indicators
|
|
7
|
+
from oda_data.api.sources import Dac1Data, Dac2aData, MultiSystemData, CrsData
|
|
8
|
+
from oda_data.tools.compatibility import ODAData
|
|
9
|
+
from oda_data.tools.groupings import donor_groupings, recipient_groupings
|
|
10
|
+
from oda_data.tools.sector_lists import add_sectors, add_broad_sectors
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def set_data_path(path):
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from oda_data.config import OdaPATHS
|
|
16
|
+
from pydeflate import set_pydeflate_path
|
|
17
|
+
|
|
18
|
+
"""Set the path to the data folder."""
|
|
19
|
+
global OdaPATHS
|
|
20
|
+
|
|
21
|
+
OdaPATHS.raw_data = Path(path).resolve()
|
|
22
|
+
set_pydeflate_path(OdaPATHS.raw_data)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"Indicators",
|
|
27
|
+
"Dac1Data",
|
|
28
|
+
"Dac2aData",
|
|
29
|
+
"MultiSystemData",
|
|
30
|
+
"CrsData",
|
|
31
|
+
"donor_groupings",
|
|
32
|
+
"recipient_groupings",
|
|
33
|
+
"add_sectors",
|
|
34
|
+
"add_broad_sectors",
|
|
35
|
+
"set_data_path",
|
|
36
|
+
"ODAData"
|
|
37
|
+
]
|