oda-data 2.2.2__tar.gz → 2.3.0__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.2.2 → oda_data-2.3.0}/PKG-INFO +205 -11
- {oda_data-2.2.2 → oda_data-2.3.0}/README.md +201 -8
- oda_data-2.3.0/pyproject.toml +119 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/api/oecd.py +15 -14
- oda_data-2.3.0/src/oda_data/api/sources.py +852 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/channels.py +14 -12
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/common.py +93 -9
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/crs_channel_mapping.csv +127 -127
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/validation.py +1 -5
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/config.py +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/common.py +2 -5
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/crs/common.py +15 -16
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/crs/crs_functions.py +22 -8
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/crs/crs_indicators.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/crs/oecd.py +4 -2
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac1/dac1_indicators.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac2a/common.py +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac2a/dac2a_indicators.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/indicator.py +2 -2
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/research/eu.py +2 -2
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/research/policy_markers.py +4 -4
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/research/sector_imputations.py +11 -12
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/crs_flow_types.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/crs_modalities.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/crs_policy_markers.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/crs_purpose.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/crs_type_of_finance.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/dac1_aid_flow_types.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/dac2a_aid_type.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/flow_types.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/indicators.json +1 -2
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/key_columns.json +1 -2
- oda_data-2.3.0/src/oda_data/settings/provider_groupings.json +325 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/recipient_groupings.json +1 -2
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/settings/v1_indicators_mapping.json +5 -3
- oda_data-2.3.0/src/oda_data/tools/cache.py +685 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/compatibility.py +1 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/gni.py +2 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/groupings.py +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/names/create_mapping.py +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/names/crs_names.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/names/dac1_names.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/names/dac2a_names.json +1 -1
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/sector_lists.py +36 -36
- oda_data-2.2.2/pyproject.toml +0 -35
- oda_data-2.2.2/src/oda_data/.raw_data/README.md +0 -3
- oda_data-2.2.2/src/oda_data/api/sources.py +0 -663
- oda_data-2.2.2/src/oda_data/settings/provider_groupings.json +0 -325
- oda_data-2.2.2/src/oda_data/tools/cache.py +0 -81
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/__init__.py +13 -13
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/api/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/api/constants.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/api/representations.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/dtypes.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/clean_data/schema.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/crs/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/crs/one.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac1/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac1/common.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac1/dac1_functions.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac1/oecd.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac1/one.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac2a/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac2a/dac2a_functions.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac2a/oecd.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/dac2a/one.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/indicators/research/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/logger.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/names/__init__.py +0 -0
- {oda_data-2.2.2 → oda_data-2.3.0}/src/oda_data/tools/names/add.py +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: oda-data
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: A python package to work with Official Development Assistance data from the OECD DAC.
|
|
5
5
|
Author: Jorge Rivera, Miguel Haro Ruiz
|
|
6
6
|
Author-email: Jorge Rivera <jorge.rivera@one.org>, Miguel Haro Ruiz <miguel.haroruiz@one.org>
|
|
7
7
|
License: MIT
|
|
8
8
|
Requires-Dist: cachetools>=6.2.0
|
|
9
|
-
Requires-Dist:
|
|
10
|
-
Requires-Dist:
|
|
9
|
+
Requires-Dist: filelock>=3.20.0
|
|
10
|
+
Requires-Dist: oda-reader>=1.3.0
|
|
11
|
+
Requires-Dist: pandas[excel,parquet,performance]>=2.2.0
|
|
11
12
|
Requires-Dist: pydeflate>=2.1.3
|
|
12
13
|
Requires-Dist: reader>=3.18
|
|
13
14
|
Requires-Dist: thefuzz>=0.22.1
|
|
@@ -19,11 +20,17 @@ Description-Content-Type: text/markdown
|
|
|
19
20
|
|
|
20
21
|
[](https://pypi.org/project/oda_data/)
|
|
21
22
|
[](https://pypi.org/project/oda_data/)
|
|
22
|
-
[](https://github.com/astral-sh/ruff)
|
|
24
|
+
[](https://github.com/ONEcampaign/oda_data_package/actions/workflows/test.yml)
|
|
25
|
+
[](https://codecov.io/gh/ONEcampaign/oda_data_package)
|
|
26
|
+
[](https://opensource.org/licenses/MIT)
|
|
27
|
+
[](https://pepy.tech/project/oda-data)
|
|
23
28
|
|
|
24
29
|
# The ODA Data Package
|
|
25
30
|
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.
|
|
26
31
|
|
|
32
|
+
**Current Version: 2.3.0**
|
|
33
|
+
|
|
27
34
|
**Note: This is the new version of the package (V2). This release includes many breaking changes and previous workflows
|
|
28
35
|
will not work. The previous 1.5.x version remains available on PyPI and we will continue to support it at least until
|
|
29
36
|
August 2025.**
|
|
@@ -34,7 +41,7 @@ of ODA, but also of how the DAC databases and tools are organised.
|
|
|
34
41
|
|
|
35
42
|
This package aims to simplify this process and make it easier for users to get the data they need.
|
|
36
43
|
|
|
37
|
-
Please submit questions, feedback or requests via
|
|
44
|
+
Please submit questions, feedback or requests via
|
|
38
45
|
the [issues page](https://github.com/ONEcampaign/oda_data_package/issues).
|
|
39
46
|
|
|
40
47
|
## Getting started
|
|
@@ -47,7 +54,7 @@ The latest version of the package can be installed using pip:
|
|
|
47
54
|
pip install oda-data --upgrade
|
|
48
55
|
```
|
|
49
56
|
|
|
50
|
-
The package is compatible with Python 3.
|
|
57
|
+
The package is compatible with Python 3.11 and above.
|
|
51
58
|
|
|
52
59
|
## Basic usage
|
|
53
60
|
|
|
@@ -58,7 +65,7 @@ An object of this class can handle:
|
|
|
58
65
|
- filtering the data for specific donors, recipients(if relevant), years.
|
|
59
66
|
- returning the data in a variety of currency/prices combinations.
|
|
60
67
|
|
|
61
|
-
At a minimum, the class expects users to specify years. By default it would then get
|
|
68
|
+
At a minimum, the class expects users to specify years. By default it would then get
|
|
62
69
|
data for all providers, for all recipients (if applicable), as net disbursements in USD, in current prices,
|
|
63
70
|
using the OECD data-explorer API.
|
|
64
71
|
|
|
@@ -124,7 +131,7 @@ data = client.get_indicators(research_indicators)
|
|
|
124
131
|
|
|
125
132
|
### OECDClient
|
|
126
133
|
|
|
127
|
-
|
|
134
|
+
Thousands of indicators are currently supported across DAC1, DAC2A, and CRS databases. These indicators are produced by filtering and sometimes aggregating data from the different DAC Tables and databases.
|
|
128
135
|
|
|
129
136
|
You can get a dictionary with all supported indicators, with their code, name, description and source by using the `.available_indicators()` method:
|
|
130
137
|
|
|
@@ -169,6 +176,38 @@ from oda_data import OECDClient
|
|
|
169
176
|
currencies = OECDClient.available_currencies()
|
|
170
177
|
```
|
|
171
178
|
|
|
179
|
+
### Measures
|
|
180
|
+
|
|
181
|
+
Different measures are available depending on the data source. Here's what each source supports:
|
|
182
|
+
|
|
183
|
+
**DAC1 Measures:**
|
|
184
|
+
- `commitment` - Total commitments
|
|
185
|
+
- `commitment_grant` - Grant commitments only
|
|
186
|
+
- `commitment_non_grant` - Non-grant commitments
|
|
187
|
+
- `grant_equivalent` - Grant equivalent values
|
|
188
|
+
- `net_disbursement` - Net disbursements (default)
|
|
189
|
+
- `net_disbursement_grant` - Net grant disbursements
|
|
190
|
+
- `gross_disbursement` - Gross disbursements
|
|
191
|
+
- `gross_disbursement_non_grant` - Gross non-grant disbursements
|
|
192
|
+
- `received` - Amounts received
|
|
193
|
+
|
|
194
|
+
**DAC2A Measures:**
|
|
195
|
+
- `net_disbursement` - Net disbursements (default)
|
|
196
|
+
- `gross_disbursement` - Gross disbursements
|
|
197
|
+
|
|
198
|
+
**CRS Measures:**
|
|
199
|
+
- `commitment` - Commitment amounts
|
|
200
|
+
- `grant_equivalent` - Grant equivalent values
|
|
201
|
+
- `gross_disbursement` - Gross disbursement amounts
|
|
202
|
+
- `received` - Amounts received
|
|
203
|
+
- `expert_commitment` - Expert commitments
|
|
204
|
+
- `expert_extended` - Expert extended
|
|
205
|
+
- `export_credit` - Export credits
|
|
206
|
+
|
|
207
|
+
**MultiSystem Measures:**
|
|
208
|
+
- `commitment` - Commitments
|
|
209
|
+
- `gross_disbursement` - Gross disbursements
|
|
210
|
+
|
|
172
211
|
## Accessing the data
|
|
173
212
|
For more advanced users, you can use this package to get and work with different tables and databases from the OECD DAC.
|
|
174
213
|
|
|
@@ -294,7 +333,7 @@ You can optionally specify:
|
|
|
294
333
|
Not specifying any or all of these parameters will return all the available data.
|
|
295
334
|
|
|
296
335
|
You can refer to the examples above for DAC1 and DAC2a to understand the usage of these classes.
|
|
297
|
-
**Note**: given the speed and rate-limiting of the dac-explorer APIs, it's recommended to always use the
|
|
336
|
+
**Note**: given the speed and rate-limiting of the dac-explorer APIs, it's recommended to always use the
|
|
298
337
|
bulk option when using the CRS class.
|
|
299
338
|
|
|
300
339
|
```python
|
|
@@ -328,11 +367,166 @@ You can refer to the examples above for DAC1 and DAC2a to understand the usage o
|
|
|
328
367
|
unless you're looking for something very specific.
|
|
329
368
|
|
|
330
369
|
|
|
370
|
+
## Utility Functions
|
|
371
|
+
|
|
372
|
+
The package provides several utility functions to enhance and enrich your ODA data analysis:
|
|
373
|
+
|
|
374
|
+
### Adding Human-Readable Names
|
|
375
|
+
|
|
376
|
+
Convert code columns to human-readable names:
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
from oda_data import OECDClient, add_names_columns
|
|
380
|
+
|
|
381
|
+
# Get indicator data
|
|
382
|
+
client = OECDClient(years=range(2020, 2023))
|
|
383
|
+
data = client.get_indicators("DAC2A.10.1010")
|
|
384
|
+
|
|
385
|
+
# Add human-readable names for code columns
|
|
386
|
+
data = add_names_columns(data, ["recipient_code", "provider_code"])
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Adding GNI Share
|
|
390
|
+
|
|
391
|
+
Calculate ODA as a percentage of Gross National Income:
|
|
392
|
+
|
|
393
|
+
```python
|
|
394
|
+
from oda_data import OECDClient, add_gni_share_column
|
|
395
|
+
|
|
396
|
+
# Create client with specific configuration
|
|
397
|
+
client = OECDClient(
|
|
398
|
+
years=range(2018, 2023),
|
|
399
|
+
providers=[4, 302], # France and USA
|
|
400
|
+
currency="USD",
|
|
401
|
+
base_year=2021
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
# Get data with GNI share column
|
|
405
|
+
data = add_gni_share_column(client, "DAC1.10.1010")
|
|
406
|
+
# Returns dataframe with 'gni_share_pct' column
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Sector Classification
|
|
410
|
+
|
|
411
|
+
Add sector classifications to your data:
|
|
412
|
+
|
|
413
|
+
```python
|
|
414
|
+
from oda_data import add_sectors, add_broad_sectors
|
|
415
|
+
|
|
416
|
+
# Add detailed sector information
|
|
417
|
+
data = add_sectors(data)
|
|
418
|
+
|
|
419
|
+
# Or add broad sector categories
|
|
420
|
+
data = add_broad_sectors(data)
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Provider and Recipient Groupings
|
|
424
|
+
|
|
425
|
+
Access predefined groupings of providers and recipients:
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
from oda_data import provider_groupings, recipient_groupings
|
|
429
|
+
|
|
430
|
+
# Get all provider groupings (DAC members, EU27, etc.)
|
|
431
|
+
providers = provider_groupings()
|
|
432
|
+
|
|
433
|
+
# Get all recipient groupings (LDCs, regions, income groups, etc.)
|
|
434
|
+
recipients = recipient_groupings()
|
|
435
|
+
|
|
436
|
+
# Example: Get all DAC members
|
|
437
|
+
dac_members = providers["dac_members"]
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Cache Management
|
|
441
|
+
|
|
442
|
+
Control the package's caching behavior:
|
|
443
|
+
|
|
444
|
+
```python
|
|
445
|
+
from oda_data import clear_cache, disable_cache, enable_cache
|
|
446
|
+
|
|
447
|
+
# Clear all cached data
|
|
448
|
+
clear_cache()
|
|
449
|
+
|
|
450
|
+
# Temporarily disable caching (for development/testing)
|
|
451
|
+
disable_cache()
|
|
452
|
+
|
|
453
|
+
# Re-enable caching
|
|
454
|
+
enable_cache()
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Compatibility with Version 1.x
|
|
458
|
+
|
|
459
|
+
For users migrating from v1.x, a compatibility layer is available:
|
|
460
|
+
|
|
461
|
+
```python
|
|
462
|
+
from oda_data import ODAData
|
|
463
|
+
|
|
464
|
+
# Use the v1.x style interface
|
|
465
|
+
oda = ODAData(years=range(2018, 2022), donors=[4, 302])
|
|
466
|
+
data = oda.load_indicator("total_oda_flow_net")
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## Advanced Features
|
|
470
|
+
|
|
471
|
+
### Policy Marker Analysis
|
|
472
|
+
|
|
473
|
+
Extract bilateral ODA by policy marker (gender, climate, etc.):
|
|
474
|
+
|
|
475
|
+
```python
|
|
476
|
+
from oda_data import bilateral_policy_marker
|
|
477
|
+
|
|
478
|
+
# Get gender-focused ODA (principal objective)
|
|
479
|
+
gender_data = bilateral_policy_marker(
|
|
480
|
+
years=range(2015, 2023),
|
|
481
|
+
providers=[4, 302],
|
|
482
|
+
marker="gender",
|
|
483
|
+
marker_score="principal",
|
|
484
|
+
measure="gross_disbursement",
|
|
485
|
+
currency="USD",
|
|
486
|
+
base_year=2021
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
# Available markers: "gender", "environment", "nutrition", "disability", "biodiversity"
|
|
490
|
+
# Available scores: "significant", "principal", "not_targeted", "not_screened",
|
|
491
|
+
# "total_targeted", "total_allocable"
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Sector Imputations
|
|
495
|
+
|
|
496
|
+
Access sector imputation functions for multilateral aid analysis:
|
|
497
|
+
|
|
498
|
+
```python
|
|
499
|
+
from oda_data.indicators.research import sector_imputations
|
|
500
|
+
|
|
501
|
+
# Use specialized sector imputation functions
|
|
502
|
+
# (See module documentation for available functions)
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### AidData Integration
|
|
506
|
+
|
|
507
|
+
Access project-level data from AidData's dataset:
|
|
508
|
+
|
|
509
|
+
```python
|
|
510
|
+
from oda_data import AidDataData, set_data_path
|
|
511
|
+
|
|
512
|
+
set_data_path("path/to/data/folder")
|
|
513
|
+
|
|
514
|
+
# Initialize AidData source
|
|
515
|
+
aiddata = AidDataData(
|
|
516
|
+
years=range(2010, 2020),
|
|
517
|
+
recipients=["Kenya", "Tanzania"],
|
|
518
|
+
sectors=[110, 120] # Sector codes
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
# Read the data (automatically uses bulk download)
|
|
522
|
+
data = aiddata.read()
|
|
523
|
+
```
|
|
524
|
+
|
|
331
525
|
## Key features
|
|
332
526
|
|
|
333
|
-
- **Speed up analysis** - The package handles downloading, cleaning and loading all the data, so you can focus on the
|
|
527
|
+
- **Speed up analysis** - The package handles downloading, cleaning and loading all the data, so you can focus on the
|
|
334
528
|
analysis.
|
|
335
|
-
- **Get data in the currency and prices you need** - ODA data is only available in US dollars (current or constant
|
|
529
|
+
- **Get data in the currency and prices you need** - ODA data is only available in US dollars (current or constant
|
|
336
530
|
prices) and local currency units (current prices). The package allows you to view the data in US dollars, Euros,
|
|
337
531
|
British Pounds and Canadian dollars, in both current and constant prices. We can add any other DAC currency if you
|
|
338
532
|
request it via the [issues page](https://github.com/ONEcampaign/oda_data_package/issues)
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
[](https://pypi.org/project/oda_data/)
|
|
2
2
|
[](https://pypi.org/project/oda_data/)
|
|
3
|
-
[](https://github.com/astral-sh/ruff)
|
|
4
|
+
[](https://github.com/ONEcampaign/oda_data_package/actions/workflows/test.yml)
|
|
5
|
+
[](https://codecov.io/gh/ONEcampaign/oda_data_package)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://pepy.tech/project/oda-data)
|
|
4
8
|
|
|
5
9
|
# The ODA Data Package
|
|
6
10
|
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
11
|
|
|
12
|
+
**Current Version: 2.3.0**
|
|
13
|
+
|
|
8
14
|
**Note: This is the new version of the package (V2). This release includes many breaking changes and previous workflows
|
|
9
15
|
will not work. The previous 1.5.x version remains available on PyPI and we will continue to support it at least until
|
|
10
16
|
August 2025.**
|
|
@@ -15,7 +21,7 @@ of ODA, but also of how the DAC databases and tools are organised.
|
|
|
15
21
|
|
|
16
22
|
This package aims to simplify this process and make it easier for users to get the data they need.
|
|
17
23
|
|
|
18
|
-
Please submit questions, feedback or requests via
|
|
24
|
+
Please submit questions, feedback or requests via
|
|
19
25
|
the [issues page](https://github.com/ONEcampaign/oda_data_package/issues).
|
|
20
26
|
|
|
21
27
|
## Getting started
|
|
@@ -28,7 +34,7 @@ The latest version of the package can be installed using pip:
|
|
|
28
34
|
pip install oda-data --upgrade
|
|
29
35
|
```
|
|
30
36
|
|
|
31
|
-
The package is compatible with Python 3.
|
|
37
|
+
The package is compatible with Python 3.11 and above.
|
|
32
38
|
|
|
33
39
|
## Basic usage
|
|
34
40
|
|
|
@@ -39,7 +45,7 @@ An object of this class can handle:
|
|
|
39
45
|
- filtering the data for specific donors, recipients(if relevant), years.
|
|
40
46
|
- returning the data in a variety of currency/prices combinations.
|
|
41
47
|
|
|
42
|
-
At a minimum, the class expects users to specify years. By default it would then get
|
|
48
|
+
At a minimum, the class expects users to specify years. By default it would then get
|
|
43
49
|
data for all providers, for all recipients (if applicable), as net disbursements in USD, in current prices,
|
|
44
50
|
using the OECD data-explorer API.
|
|
45
51
|
|
|
@@ -105,7 +111,7 @@ data = client.get_indicators(research_indicators)
|
|
|
105
111
|
|
|
106
112
|
### OECDClient
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
Thousands of indicators are currently supported across DAC1, DAC2A, and CRS databases. These indicators are produced by filtering and sometimes aggregating data from the different DAC Tables and databases.
|
|
109
115
|
|
|
110
116
|
You can get a dictionary with all supported indicators, with their code, name, description and source by using the `.available_indicators()` method:
|
|
111
117
|
|
|
@@ -150,6 +156,38 @@ from oda_data import OECDClient
|
|
|
150
156
|
currencies = OECDClient.available_currencies()
|
|
151
157
|
```
|
|
152
158
|
|
|
159
|
+
### Measures
|
|
160
|
+
|
|
161
|
+
Different measures are available depending on the data source. Here's what each source supports:
|
|
162
|
+
|
|
163
|
+
**DAC1 Measures:**
|
|
164
|
+
- `commitment` - Total commitments
|
|
165
|
+
- `commitment_grant` - Grant commitments only
|
|
166
|
+
- `commitment_non_grant` - Non-grant commitments
|
|
167
|
+
- `grant_equivalent` - Grant equivalent values
|
|
168
|
+
- `net_disbursement` - Net disbursements (default)
|
|
169
|
+
- `net_disbursement_grant` - Net grant disbursements
|
|
170
|
+
- `gross_disbursement` - Gross disbursements
|
|
171
|
+
- `gross_disbursement_non_grant` - Gross non-grant disbursements
|
|
172
|
+
- `received` - Amounts received
|
|
173
|
+
|
|
174
|
+
**DAC2A Measures:**
|
|
175
|
+
- `net_disbursement` - Net disbursements (default)
|
|
176
|
+
- `gross_disbursement` - Gross disbursements
|
|
177
|
+
|
|
178
|
+
**CRS Measures:**
|
|
179
|
+
- `commitment` - Commitment amounts
|
|
180
|
+
- `grant_equivalent` - Grant equivalent values
|
|
181
|
+
- `gross_disbursement` - Gross disbursement amounts
|
|
182
|
+
- `received` - Amounts received
|
|
183
|
+
- `expert_commitment` - Expert commitments
|
|
184
|
+
- `expert_extended` - Expert extended
|
|
185
|
+
- `export_credit` - Export credits
|
|
186
|
+
|
|
187
|
+
**MultiSystem Measures:**
|
|
188
|
+
- `commitment` - Commitments
|
|
189
|
+
- `gross_disbursement` - Gross disbursements
|
|
190
|
+
|
|
153
191
|
## Accessing the data
|
|
154
192
|
For more advanced users, you can use this package to get and work with different tables and databases from the OECD DAC.
|
|
155
193
|
|
|
@@ -275,7 +313,7 @@ You can optionally specify:
|
|
|
275
313
|
Not specifying any or all of these parameters will return all the available data.
|
|
276
314
|
|
|
277
315
|
You can refer to the examples above for DAC1 and DAC2a to understand the usage of these classes.
|
|
278
|
-
**Note**: given the speed and rate-limiting of the dac-explorer APIs, it's recommended to always use the
|
|
316
|
+
**Note**: given the speed and rate-limiting of the dac-explorer APIs, it's recommended to always use the
|
|
279
317
|
bulk option when using the CRS class.
|
|
280
318
|
|
|
281
319
|
```python
|
|
@@ -309,11 +347,166 @@ You can refer to the examples above for DAC1 and DAC2a to understand the usage o
|
|
|
309
347
|
unless you're looking for something very specific.
|
|
310
348
|
|
|
311
349
|
|
|
350
|
+
## Utility Functions
|
|
351
|
+
|
|
352
|
+
The package provides several utility functions to enhance and enrich your ODA data analysis:
|
|
353
|
+
|
|
354
|
+
### Adding Human-Readable Names
|
|
355
|
+
|
|
356
|
+
Convert code columns to human-readable names:
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
from oda_data import OECDClient, add_names_columns
|
|
360
|
+
|
|
361
|
+
# Get indicator data
|
|
362
|
+
client = OECDClient(years=range(2020, 2023))
|
|
363
|
+
data = client.get_indicators("DAC2A.10.1010")
|
|
364
|
+
|
|
365
|
+
# Add human-readable names for code columns
|
|
366
|
+
data = add_names_columns(data, ["recipient_code", "provider_code"])
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Adding GNI Share
|
|
370
|
+
|
|
371
|
+
Calculate ODA as a percentage of Gross National Income:
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
from oda_data import OECDClient, add_gni_share_column
|
|
375
|
+
|
|
376
|
+
# Create client with specific configuration
|
|
377
|
+
client = OECDClient(
|
|
378
|
+
years=range(2018, 2023),
|
|
379
|
+
providers=[4, 302], # France and USA
|
|
380
|
+
currency="USD",
|
|
381
|
+
base_year=2021
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
# Get data with GNI share column
|
|
385
|
+
data = add_gni_share_column(client, "DAC1.10.1010")
|
|
386
|
+
# Returns dataframe with 'gni_share_pct' column
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Sector Classification
|
|
390
|
+
|
|
391
|
+
Add sector classifications to your data:
|
|
392
|
+
|
|
393
|
+
```python
|
|
394
|
+
from oda_data import add_sectors, add_broad_sectors
|
|
395
|
+
|
|
396
|
+
# Add detailed sector information
|
|
397
|
+
data = add_sectors(data)
|
|
398
|
+
|
|
399
|
+
# Or add broad sector categories
|
|
400
|
+
data = add_broad_sectors(data)
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Provider and Recipient Groupings
|
|
404
|
+
|
|
405
|
+
Access predefined groupings of providers and recipients:
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
from oda_data import provider_groupings, recipient_groupings
|
|
409
|
+
|
|
410
|
+
# Get all provider groupings (DAC members, EU27, etc.)
|
|
411
|
+
providers = provider_groupings()
|
|
412
|
+
|
|
413
|
+
# Get all recipient groupings (LDCs, regions, income groups, etc.)
|
|
414
|
+
recipients = recipient_groupings()
|
|
415
|
+
|
|
416
|
+
# Example: Get all DAC members
|
|
417
|
+
dac_members = providers["dac_members"]
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Cache Management
|
|
421
|
+
|
|
422
|
+
Control the package's caching behavior:
|
|
423
|
+
|
|
424
|
+
```python
|
|
425
|
+
from oda_data import clear_cache, disable_cache, enable_cache
|
|
426
|
+
|
|
427
|
+
# Clear all cached data
|
|
428
|
+
clear_cache()
|
|
429
|
+
|
|
430
|
+
# Temporarily disable caching (for development/testing)
|
|
431
|
+
disable_cache()
|
|
432
|
+
|
|
433
|
+
# Re-enable caching
|
|
434
|
+
enable_cache()
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Compatibility with Version 1.x
|
|
438
|
+
|
|
439
|
+
For users migrating from v1.x, a compatibility layer is available:
|
|
440
|
+
|
|
441
|
+
```python
|
|
442
|
+
from oda_data import ODAData
|
|
443
|
+
|
|
444
|
+
# Use the v1.x style interface
|
|
445
|
+
oda = ODAData(years=range(2018, 2022), donors=[4, 302])
|
|
446
|
+
data = oda.load_indicator("total_oda_flow_net")
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Advanced Features
|
|
450
|
+
|
|
451
|
+
### Policy Marker Analysis
|
|
452
|
+
|
|
453
|
+
Extract bilateral ODA by policy marker (gender, climate, etc.):
|
|
454
|
+
|
|
455
|
+
```python
|
|
456
|
+
from oda_data import bilateral_policy_marker
|
|
457
|
+
|
|
458
|
+
# Get gender-focused ODA (principal objective)
|
|
459
|
+
gender_data = bilateral_policy_marker(
|
|
460
|
+
years=range(2015, 2023),
|
|
461
|
+
providers=[4, 302],
|
|
462
|
+
marker="gender",
|
|
463
|
+
marker_score="principal",
|
|
464
|
+
measure="gross_disbursement",
|
|
465
|
+
currency="USD",
|
|
466
|
+
base_year=2021
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
# Available markers: "gender", "environment", "nutrition", "disability", "biodiversity"
|
|
470
|
+
# Available scores: "significant", "principal", "not_targeted", "not_screened",
|
|
471
|
+
# "total_targeted", "total_allocable"
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Sector Imputations
|
|
475
|
+
|
|
476
|
+
Access sector imputation functions for multilateral aid analysis:
|
|
477
|
+
|
|
478
|
+
```python
|
|
479
|
+
from oda_data.indicators.research import sector_imputations
|
|
480
|
+
|
|
481
|
+
# Use specialized sector imputation functions
|
|
482
|
+
# (See module documentation for available functions)
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### AidData Integration
|
|
486
|
+
|
|
487
|
+
Access project-level data from AidData's dataset:
|
|
488
|
+
|
|
489
|
+
```python
|
|
490
|
+
from oda_data import AidDataData, set_data_path
|
|
491
|
+
|
|
492
|
+
set_data_path("path/to/data/folder")
|
|
493
|
+
|
|
494
|
+
# Initialize AidData source
|
|
495
|
+
aiddata = AidDataData(
|
|
496
|
+
years=range(2010, 2020),
|
|
497
|
+
recipients=["Kenya", "Tanzania"],
|
|
498
|
+
sectors=[110, 120] # Sector codes
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
# Read the data (automatically uses bulk download)
|
|
502
|
+
data = aiddata.read()
|
|
503
|
+
```
|
|
504
|
+
|
|
312
505
|
## Key features
|
|
313
506
|
|
|
314
|
-
- **Speed up analysis** - The package handles downloading, cleaning and loading all the data, so you can focus on the
|
|
507
|
+
- **Speed up analysis** - The package handles downloading, cleaning and loading all the data, so you can focus on the
|
|
315
508
|
analysis.
|
|
316
|
-
- **Get data in the currency and prices you need** - ODA data is only available in US dollars (current or constant
|
|
509
|
+
- **Get data in the currency and prices you need** - ODA data is only available in US dollars (current or constant
|
|
317
510
|
prices) and local currency units (current prices). The package allows you to view the data in US dollars, Euros,
|
|
318
511
|
British Pounds and Canadian dollars, in both current and constant prices. We can add any other DAC currency if you
|
|
319
512
|
request it via the [issues page](https://github.com/ONEcampaign/oda_data_package/issues)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "oda_data"
|
|
3
|
+
version = "2.3.0"
|
|
4
|
+
description = "A python package to work with Official Development Assistance data from the OECD DAC."
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
|
|
7
|
+
license = {text = "MIT"}
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "Jorge Rivera", email = "jorge.rivera@one.org"},
|
|
11
|
+
{name = "Miguel Haro Ruiz", email = "miguel.haroruiz@one.org"}
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
dependencies = [
|
|
15
|
+
"cachetools>=6.2.0",
|
|
16
|
+
"filelock>=3.20.0",
|
|
17
|
+
"oda-reader>=1.3.0",
|
|
18
|
+
"pandas[excel,parquet,performance]>=2.2.0",
|
|
19
|
+
"pydeflate>=2.1.3",
|
|
20
|
+
"reader>=3.18",
|
|
21
|
+
"thefuzz>=0.22.1",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/ONEcampaign/oda_data_package"
|
|
26
|
+
Repository = "https://github.com/ONEcampaign/oda_data_package"
|
|
27
|
+
Documentation = "https://github.com/ONEcampaign/oda_data_package"
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["uv_build>=0.8.22,<0.9.0"]
|
|
31
|
+
build-backend = "uv_build"
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
"uv-build>=0.8.22",
|
|
36
|
+
"pre-commit>=4.0.0",
|
|
37
|
+
"ruff>=0.14.0",
|
|
38
|
+
]
|
|
39
|
+
test = [
|
|
40
|
+
"pytest>=8.0.0",
|
|
41
|
+
"pytest-mock>=3.12.0",
|
|
42
|
+
"pytest-cov>=4.1.0",
|
|
43
|
+
"pytest-xdist>=3.5.0",
|
|
44
|
+
"freezegun>=1.4.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
# Set the maximum line length
|
|
49
|
+
line-length = 88
|
|
50
|
+
|
|
51
|
+
# Target Python 3.11+
|
|
52
|
+
target-version = "py311"
|
|
53
|
+
|
|
54
|
+
# Exclude common directories
|
|
55
|
+
exclude = [
|
|
56
|
+
".git",
|
|
57
|
+
".venv",
|
|
58
|
+
"venv",
|
|
59
|
+
"__pycache__",
|
|
60
|
+
"build",
|
|
61
|
+
"dist",
|
|
62
|
+
"*.egg-info",
|
|
63
|
+
".pytest_cache",
|
|
64
|
+
"htmlcov",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint]
|
|
68
|
+
# Enable recommended rules plus extras
|
|
69
|
+
select = [
|
|
70
|
+
"E", # pycodestyle errors
|
|
71
|
+
"W", # pycodestyle warnings
|
|
72
|
+
"F", # pyflakes
|
|
73
|
+
"I", # isort
|
|
74
|
+
"N", # pep8-naming
|
|
75
|
+
"UP", # pyupgrade
|
|
76
|
+
"B", # flake8-bugbear
|
|
77
|
+
"C4", # flake8-comprehensions
|
|
78
|
+
"SIM", # flake8-simplify
|
|
79
|
+
"PL", # pylint
|
|
80
|
+
"RUF", # ruff-specific rules
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
# Ignore specific rules that might be too strict
|
|
84
|
+
ignore = [
|
|
85
|
+
"E501", # Line too long (handled by formatter)
|
|
86
|
+
"PLR0913", # Too many arguments
|
|
87
|
+
"PLR2004", # Magic value used in comparison
|
|
88
|
+
"PLC0415", # Import outside top-level (used to avoid circular imports)
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
# Allow autofix for all enabled rules
|
|
92
|
+
fixable = ["ALL"]
|
|
93
|
+
unfixable = []
|
|
94
|
+
|
|
95
|
+
[tool.ruff.lint.per-file-ignores]
|
|
96
|
+
# Allow test files to have longer lines and more assertions
|
|
97
|
+
"tests/**/*.py" = ["E501", "PLR2004", "RUF002", "RUF003"] # Allow × in comments/docstrings
|
|
98
|
+
# Allow global variable usage in __init__.py (architectural decision)
|
|
99
|
+
"src/oda_data/__init__.py" = ["PLW0603", "PLW0602", "F811"]
|
|
100
|
+
# Allow tmpdir reassignment pattern (Path conversion)
|
|
101
|
+
"src/oda_data/tools/cache.py" = ["PLW2901"]
|
|
102
|
+
# Allow loop variable binding patterns (intentional for lambda closures)
|
|
103
|
+
"src/oda_data/indicators/crs/crs_functions.py" = ["B023"]
|
|
104
|
+
"src/oda_data/indicators/research/sector_imputations.py" = ["B023"]
|
|
105
|
+
# Allow mixedCase variable names matching official sector code names
|
|
106
|
+
"src/oda_data/tools/sector_lists.py" = ["N816"]
|
|
107
|
+
|
|
108
|
+
[tool.ruff.format]
|
|
109
|
+
# Use double quotes for strings
|
|
110
|
+
quote-style = "double"
|
|
111
|
+
|
|
112
|
+
# Use spaces for indentation
|
|
113
|
+
indent-style = "space"
|
|
114
|
+
|
|
115
|
+
# Like Black, respect magic trailing commas
|
|
116
|
+
skip-magic-trailing-comma = false
|
|
117
|
+
|
|
118
|
+
# Like Black, automatically detect line endings
|
|
119
|
+
line-ending = "auto"
|