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.
Files changed (25) hide show
  1. {pydeflate-2.0.0 → pydeflate-2.0.1}/PKG-INFO +1 -1
  2. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/__init__.py +1 -1
  3. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/api.py +2 -2
  4. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/exchange.py +6 -4
  5. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/common.py +10 -1
  6. {pydeflate-2.0.0 → pydeflate-2.0.1}/pyproject.toml +1 -1
  7. {pydeflate-2.0.0 → pydeflate-2.0.1}/LICENSE +0 -0
  8. {pydeflate-2.0.0 → pydeflate-2.0.1}/README.md +0 -0
  9. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/.pydeflate_data/README.md +0 -0
  10. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/__init__.py +0 -0
  11. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/deflator.py +0 -0
  12. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/core/source.py +0 -0
  13. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/deflate/__init__.py +0 -0
  14. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/deflate/deflators.py +0 -0
  15. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/deflate/legacy_deflate.py +0 -0
  16. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/exchange/__init__.py +0 -0
  17. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/exchange/exchangers.py +0 -0
  18. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/pydeflate_config.py +0 -0
  19. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/settings/emu.json +0 -0
  20. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/settings/oecd_codes.json +0 -0
  21. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/__init__.py +0 -0
  22. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/dac.py +0 -0
  23. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/imf.py +0 -0
  24. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/sources/world_bank.py +0 -0
  25. {pydeflate-2.0.0 → pydeflate-2.0.1}/pydeflate/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pydeflate
3
- Version: 2.0.0
3
+ Version: 2.0.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
@@ -1,5 +1,5 @@
1
1
  __author__ = """Jorge Rivera"""
2
- __version__ = "2.0.0"
2
+ __version__ = "2.0.1"
3
3
 
4
4
  from pydeflate.deflate.deflators import (
5
5
  oecd_dac_deflate,
@@ -318,9 +318,9 @@ class BaseDeflate:
318
318
  pd.Series: Series with combined deflator values.
319
319
  """
320
320
  return (
321
- (10_000 * exchange_rate) / (price_def * exchange_def)
321
+ (exchange_def * exchange_rate) / price_def
322
322
  if self.to_current
323
- else (price_def * exchange_def) / (10_000 * exchange_rate)
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="pydeflate_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"{exchange}_D"] = round(100 * group[exchange] / base_value[0], 6)
232
+ group[f"{exchange_name}_D"] = round(
233
+ 100 * group[exchange] / base_value[0], 6
234
+ )
226
235
 
227
236
  return group
228
237
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pydeflate"
3
- version = "2.0.0"
3
+ version = "2.0.1"
4
4
  description = "Package to convert current prices figures to constant prices and vice versa"
5
5
  authors = ["Jorge Rivera <jorge.rivera@one.org>"]
6
6
  license = "MIT"
File without changes
File without changes
File without changes