pydeflate 2.1.0__py3-none-any.whl → 2.1.1__py3-none-any.whl
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.
- pydeflate/__init__.py +1 -1
- pydeflate/core/api.py +5 -0
- pydeflate/utils.py +59 -4
- {pydeflate-2.1.0.dist-info → pydeflate-2.1.1.dist-info}/METADATA +9 -12
- {pydeflate-2.1.0.dist-info → pydeflate-2.1.1.dist-info}/RECORD +7 -7
- {pydeflate-2.1.0.dist-info → pydeflate-2.1.1.dist-info}/WHEEL +1 -1
- {pydeflate-2.1.0.dist-info → pydeflate-2.1.1.dist-info}/LICENSE +0 -0
pydeflate/__init__.py
CHANGED
pydeflate/core/api.py
CHANGED
|
@@ -176,6 +176,8 @@ class BaseExchange:
|
|
|
176
176
|
pydeflate_data=self.pydeflate_data,
|
|
177
177
|
entity_column=entity_column,
|
|
178
178
|
ix=self._idx,
|
|
179
|
+
source_codes=self._idx[-1] == "pydeflate_entity_code",
|
|
180
|
+
dac=self.exchange_rates.source.name == "DAC",
|
|
179
181
|
)
|
|
180
182
|
|
|
181
183
|
# store unmatched data
|
|
@@ -365,6 +367,9 @@ class BaseDeflate:
|
|
|
365
367
|
pydeflate_data=self.pydeflate_data,
|
|
366
368
|
entity_column=entity_column,
|
|
367
369
|
ix=self._idx,
|
|
370
|
+
source_codes=self.use_source_codes,
|
|
371
|
+
dac=self.exchange_deflator.source.name == "DAC"
|
|
372
|
+
or self.price_deflator.source.name == "DAC",
|
|
368
373
|
)
|
|
369
374
|
|
|
370
375
|
# store unmatched data
|
pydeflate/utils.py
CHANGED
|
@@ -51,21 +51,68 @@ def create_pydeflate_year(
|
|
|
51
51
|
return data
|
|
52
52
|
|
|
53
53
|
|
|
54
|
+
def _use_implied_dac_rates(
|
|
55
|
+
data: pd.DataFrame,
|
|
56
|
+
pydeflate_data: pd.DataFrame,
|
|
57
|
+
ix: list[str],
|
|
58
|
+
entity_column: str,
|
|
59
|
+
source_codes: bool,
|
|
60
|
+
) -> pd.DataFrame:
|
|
61
|
+
"""When rates are missing for entities in DAC data, the correct behaviour is to use
|
|
62
|
+
the DAC overall rates"""
|
|
63
|
+
|
|
64
|
+
# Assign the DAC code to a temporary column
|
|
65
|
+
data.loc[
|
|
66
|
+
lambda d: ~d[f"temp_{entity_column}"].isin(pydeflate_data[ix[-1]].unique()),
|
|
67
|
+
f"temp_{entity_column}",
|
|
68
|
+
] = (
|
|
69
|
+
20001 if source_codes else "DAC"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Log the fact that implied rates are being used
|
|
73
|
+
flag_missing_pydeflate_data(
|
|
74
|
+
unmatched_data=data.loc[
|
|
75
|
+
lambda d: ~d[f"{entity_column}"].isin(pydeflate_data[ix[-1]].unique())
|
|
76
|
+
],
|
|
77
|
+
entity_column=entity_column,
|
|
78
|
+
year_column="pydeflate_year",
|
|
79
|
+
using_implied=True,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return data
|
|
83
|
+
|
|
84
|
+
|
|
54
85
|
def merge_user_and_pydeflate_data(
|
|
55
86
|
data: pd.DataFrame,
|
|
56
87
|
pydeflate_data: pd.DataFrame,
|
|
57
88
|
entity_column: str,
|
|
58
89
|
ix: list[str],
|
|
90
|
+
source_codes: bool = True,
|
|
91
|
+
dac: bool = False,
|
|
59
92
|
) -> pd.DataFrame:
|
|
60
|
-
|
|
93
|
+
|
|
94
|
+
data[f"temp_{entity_column}"] = data[entity_column]
|
|
95
|
+
|
|
96
|
+
if dac:
|
|
97
|
+
data = _use_implied_dac_rates(
|
|
98
|
+
data=data,
|
|
99
|
+
pydeflate_data=pydeflate_data,
|
|
100
|
+
ix=ix,
|
|
101
|
+
entity_column=entity_column,
|
|
102
|
+
source_codes=source_codes,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
df_ = data.merge(
|
|
61
106
|
pydeflate_data,
|
|
62
107
|
how="outer",
|
|
63
|
-
left_on=["pydeflate_year", entity_column],
|
|
108
|
+
left_on=["pydeflate_year", f"temp_{entity_column}"],
|
|
64
109
|
right_on=ix,
|
|
65
110
|
suffixes=("", "_pydeflate"),
|
|
66
111
|
indicator=True,
|
|
67
112
|
).pipe(enforce_pyarrow_types)
|
|
68
113
|
|
|
114
|
+
return df_.drop(columns=[f"temp_{entity_column}"])
|
|
115
|
+
|
|
69
116
|
|
|
70
117
|
def get_unmatched_pydeflate_data(
|
|
71
118
|
merged_data: pd.DataFrame,
|
|
@@ -86,7 +133,10 @@ def get_matched_pydeflate_data(
|
|
|
86
133
|
|
|
87
134
|
|
|
88
135
|
def flag_missing_pydeflate_data(
|
|
89
|
-
unmatched_data: pd.DataFrame,
|
|
136
|
+
unmatched_data: pd.DataFrame,
|
|
137
|
+
entity_column: str,
|
|
138
|
+
year_column: str,
|
|
139
|
+
using_implied: bool = False,
|
|
90
140
|
):
|
|
91
141
|
"""Flag data which is present in the input data but missing in pydeflate's data."""
|
|
92
142
|
if unmatched_data.empty:
|
|
@@ -102,4 +152,9 @@ def flag_missing_pydeflate_data(
|
|
|
102
152
|
missing_str = "\n".join(f"{entity}: {years}" for entity, years in missing.items())
|
|
103
153
|
|
|
104
154
|
# log all missing data
|
|
105
|
-
|
|
155
|
+
message = (
|
|
156
|
+
"Using DAC members' rates (given missing data) for:"
|
|
157
|
+
if using_implied
|
|
158
|
+
else "Missing exchange data for:"
|
|
159
|
+
)
|
|
160
|
+
logger.info(f"{message}\n{missing_str}")
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: pydeflate
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: Package to convert current prices figures to constant prices and vice versa
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Jorge Rivera
|
|
7
7
|
Author-email: jorge.rivera@one.org
|
|
8
|
-
Requires-Python: >=3.10
|
|
9
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
-
Classifier: Intended Audience :: End Users/Desktop
|
|
11
|
-
Classifier: Intended Audience :: Science/Research
|
|
8
|
+
Requires-Python: >=3.10, <4.0
|
|
12
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Natural Language :: English
|
|
14
10
|
Classifier: Programming Language :: Python :: 3
|
|
15
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Requires-Dist: hdx-python-country (>=3.8
|
|
20
|
-
Requires-Dist: imf-reader (>=1.
|
|
21
|
-
Requires-Dist: oda-reader (>=1.0.
|
|
22
|
-
Requires-Dist: pandas (>=2,<3)
|
|
23
|
-
Requires-Dist: pyarrow (
|
|
15
|
+
Requires-Dist: hdx-python-country (>=3.8,<4.0.0)
|
|
16
|
+
Requires-Dist: imf-reader (>=1.2.0,<2.0.0)
|
|
17
|
+
Requires-Dist: oda-reader (>=1.0.5,<2.0.0)
|
|
18
|
+
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
19
|
+
Requires-Dist: pyarrow (>=14.0)
|
|
20
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
24
21
|
Requires-Dist: wbgapi (>=1.0.12,<2.0.0)
|
|
25
22
|
Description-Content-Type: text/markdown
|
|
26
23
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
pydeflate/.pydeflate_data/README.md,sha256=atNtUL9dD8G184YSd6juFib8TgEQBcSLogiz99APPVs,25
|
|
2
|
-
pydeflate/__init__.py,sha256=
|
|
2
|
+
pydeflate/__init__.py,sha256=JJqxQpHXxfqzada3FkaneDTW9BlNM40CBwjJgEZZ4tQ,1013
|
|
3
3
|
pydeflate/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
pydeflate/core/api.py,sha256=
|
|
4
|
+
pydeflate/core/api.py,sha256=mD5zhGlAIvlpT6KcmrHW5rmYwtEq5x2Pqo-jQCQMGpo,14687
|
|
5
5
|
pydeflate/core/deflator.py,sha256=Ax3dmOF3tYRZnkIfFvMMo3SOLgAJHkXSmA-OtIUZkp0,5932
|
|
6
6
|
pydeflate/core/exchange.py,sha256=br6RVgTGa7LW09XemUJZ4Koazf65zuXPQKYKGhS6ROM,8535
|
|
7
7
|
pydeflate/core/source.py,sha256=n603ocgGjthXNcBWwgADkefxWmSFuN77Km9Z0T2zpIg,2027
|
|
@@ -18,8 +18,8 @@ pydeflate/sources/common.py,sha256=TvoN3jnqn0xXNuxM52vvgSLA5WRGX8PUD-b5YH6S7GE,9
|
|
|
18
18
|
pydeflate/sources/dac.py,sha256=ngFiApGZ_tIQg74ogGVTIbGUA0efnF1SYwfUuqGofOQ,3791
|
|
19
19
|
pydeflate/sources/imf.py,sha256=10vc8xhNJvANb7RDD1WFn9oaZ8g53yUV5LxCQCz6ImM,6337
|
|
20
20
|
pydeflate/sources/world_bank.py,sha256=uMHidFVgEpj1HVUnNhIZV-rV64hsCBV9ZAbYKk6H0Vw,9333
|
|
21
|
-
pydeflate/utils.py,sha256=
|
|
22
|
-
pydeflate-2.1.
|
|
23
|
-
pydeflate-2.1.
|
|
24
|
-
pydeflate-2.1.
|
|
25
|
-
pydeflate-2.1.
|
|
21
|
+
pydeflate/utils.py,sha256=tJBd271WzZxVhW9ZMiIRHR0fZWr_MagAYLdmXXaUY3M,3983
|
|
22
|
+
pydeflate-2.1.1.dist-info/LICENSE,sha256=q5tm9mQxwSbV5Ivvjxs7MMqBgan6DM8I4r4irPvmqZM,1075
|
|
23
|
+
pydeflate-2.1.1.dist-info/METADATA,sha256=9_x0yAsOsj70V9dESsz9C89UuQuxc_TTQkyamDDXne4,12437
|
|
24
|
+
pydeflate-2.1.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
25
|
+
pydeflate-2.1.1.dist-info/RECORD,,
|
|
File without changes
|