pydeflate 2.0.0__tar.gz → 2.0.1__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.
- {pydeflate-2.0.0 → pydeflate-2.0.1}/PKG-INFO +1 -1
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/__init__.py +1 -1
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/api.py +2 -2
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/exchange.py +6 -4
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/common.py +10 -1
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pyproject.toml +1 -1
- {pydeflate-2.0.0 → pydeflate-2.0.1}/LICENSE +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/README.md +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/.pydeflate_data/README.md +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/__init__.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/deflator.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/source.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/deflate/__init__.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/deflate/deflators.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/deflate/legacy_deflate.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/exchange/__init__.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/exchange/exchangers.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/pydeflate_config.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/settings/emu.json +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/settings/oecd_codes.json +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/__init__.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/dac.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/imf.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/world_bank.py +0 -0
- {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/utils.py +0 -0
|
@@ -318,9 +318,9 @@ class BaseDeflate:
|
|
|
318
318
|
pd.Series: Series with combined deflator values.
|
|
319
319
|
"""
|
|
320
320
|
return (
|
|
321
|
-
(
|
|
321
|
+
(exchange_def * exchange_rate) / price_def
|
|
322
322
|
if self.to_current
|
|
323
|
-
else
|
|
323
|
+
else price_def / (exchange_def * exchange_rate)
|
|
324
324
|
)
|
|
325
325
|
|
|
326
326
|
def _merge_components(self, df: pd.DataFrame, other: pd.DataFrame):
|
|
@@ -37,6 +37,8 @@ class Exchange:
|
|
|
37
37
|
self.exchange_data = self.exchange_rate(
|
|
38
38
|
self.source_currency, self.target_currency
|
|
39
39
|
)
|
|
40
|
+
if self.source_currency == "USA":
|
|
41
|
+
self.exchange_data["pydeflate_EXCHANGE_D"] = 1
|
|
40
42
|
|
|
41
43
|
def _get_exchange_rate(self, currency):
|
|
42
44
|
"""Helper function to fetch exchange rates for a given currency."""
|
|
@@ -110,17 +112,17 @@ class Exchange:
|
|
|
110
112
|
pydeflate_EXCHANGE=lambda d: d.pydeflate_EXCHANGE / d.pydeflate_EXCHANGE_to
|
|
111
113
|
)
|
|
112
114
|
|
|
113
|
-
# Drop unnecessary columns
|
|
114
|
-
merged = merged.drop(columns=merged.filter(regex="_to$").columns, axis=1)
|
|
115
|
-
|
|
116
115
|
# Compute the exchange rate deflator
|
|
117
116
|
merged = compute_exchange_deflator(
|
|
118
117
|
merged,
|
|
119
|
-
exchange="
|
|
118
|
+
exchange="pydeflate_EXCHANGE_to",
|
|
120
119
|
year="pydeflate_year",
|
|
121
120
|
grouper=["pydeflate_entity_code", "pydeflate_iso3"],
|
|
122
121
|
)
|
|
123
122
|
|
|
123
|
+
# Drop unnecessary columns
|
|
124
|
+
merged = merged.drop(columns=merged.filter(regex="_to$").columns, axis=1)
|
|
125
|
+
|
|
124
126
|
return merged
|
|
125
127
|
|
|
126
128
|
def exchange(
|
|
@@ -207,6 +207,13 @@ def compute_exchange_deflator(
|
|
|
207
207
|
exchange: str = "EXCHANGE",
|
|
208
208
|
year: str = "year",
|
|
209
209
|
) -> pd.DataFrame:
|
|
210
|
+
|
|
211
|
+
# if needed, clean exchange name
|
|
212
|
+
if exchange.endswith("_to") or exchange.endswith("_from"):
|
|
213
|
+
exchange_name = exchange.rsplit("_", 1)[0]
|
|
214
|
+
else:
|
|
215
|
+
exchange_name = exchange
|
|
216
|
+
|
|
210
217
|
# Identify the base year for the deflator
|
|
211
218
|
if measure is not None:
|
|
212
219
|
base_year = identify_base_year(group, measure=measure, year=year)
|
|
@@ -222,7 +229,9 @@ def compute_exchange_deflator(
|
|
|
222
229
|
|
|
223
230
|
# If base value is found and valid, calculate the deflator
|
|
224
231
|
if base_value.size > 0 and pd.notna(base_value[0]):
|
|
225
|
-
group[f"{
|
|
232
|
+
group[f"{exchange_name}_D"] = round(
|
|
233
|
+
100 * group[exchange] / base_value[0], 6
|
|
234
|
+
)
|
|
226
235
|
|
|
227
236
|
return group
|
|
228
237
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|