pydeflate 2.1.2__tar.gz → 2.1.3__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.1.2 → pydeflate-2.1.3}/PKG-INFO +1 -1
  2. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/__init__.py +1 -1
  3. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/core/api.py +1 -1
  4. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/exchange/exchangers.py +0 -1
  5. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/sources/common.py +1 -0
  6. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/sources/imf.py +29 -0
  7. {pydeflate-2.1.2 → pydeflate-2.1.3}/pyproject.toml +1 -1
  8. {pydeflate-2.1.2 → pydeflate-2.1.3}/LICENSE +0 -0
  9. {pydeflate-2.1.2 → pydeflate-2.1.3}/README.md +0 -0
  10. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/.pydeflate_data/README.md +0 -0
  11. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/core/__init__.py +0 -0
  12. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/core/deflator.py +0 -0
  13. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/core/exchange.py +0 -0
  14. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/core/source.py +0 -0
  15. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/deflate/__init__.py +0 -0
  16. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/deflate/deflators.py +0 -0
  17. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/deflate/legacy_deflate.py +0 -0
  18. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/exchange/__init__.py +0 -0
  19. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/pydeflate_config.py +0 -0
  20. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/settings/emu.json +0 -0
  21. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/settings/oecd_codes.json +0 -0
  22. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/sources/__init__.py +0 -0
  23. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/sources/dac.py +0 -0
  24. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/sources/world_bank.py +0 -0
  25. {pydeflate-2.1.2 → pydeflate-2.1.3}/pydeflate/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pydeflate
3
- Version: 2.1.2
3
+ Version: 2.1.3
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.1.2"
2
+ __version__ = "2.1.3"
3
3
 
4
4
  from pydeflate.deflate.deflators import (
5
5
  oecd_dac_deflate,
@@ -16,7 +16,7 @@ from pydeflate.utils import (
16
16
  def resolve_common_currencies(currency: str, source: str) -> str:
17
17
  mapping = {
18
18
  "USD": "USA",
19
- "EUR": "EMU",
19
+ "EUR": "EUR",
20
20
  "GBP": "GBR",
21
21
  "JPY": "JPN",
22
22
  "CAD": "CAN",
@@ -1,7 +1,6 @@
1
1
  from functools import wraps
2
2
 
3
3
  import pandas as pd
4
- from frictionless.console.common import source
5
4
 
6
5
  from pydeflate.core.api import BaseExchange
7
6
  from pydeflate.core.source import DAC, WorldBank, IMF, WorldBankPPP
@@ -133,6 +133,7 @@ def add_pydeflate_iso3(
133
133
  not_found=fillna,
134
134
  additional_mapping={
135
135
  "World": "WLD",
136
+ "European Union": "EUR",
136
137
  "EU Institutions": "EUI",
137
138
  "DAC countries": "DAC",
138
139
  "Kosovo": "XXK",
@@ -147,6 +147,34 @@ def _compute_exchange(df: pd.DataFrame) -> pd.DataFrame:
147
147
  return pd.concat([df, exchange], ignore_index=True)
148
148
 
149
149
 
150
+ def _create_eur_series(df: pd.DataFrame) -> pd.DataFrame:
151
+ """Create a EUR series from the exchange rate data.
152
+
153
+ This function creates exchange rate data for EUR by using the exchange rate
154
+ from France starting from 1999.
155
+
156
+ Args:
157
+ df (pd.DataFrame): DataFrame containing exchange rates.
158
+
159
+ Returns:
160
+ pd.DataFrame: DataFrame with the EUR exchange rate.
161
+ """
162
+
163
+ # Get France's exchange rates by year
164
+ eur = (
165
+ df.loc[lambda d: d.pydeflate_iso3 == "FRA"]
166
+ .loc[lambda d: d.year >= 1999]
167
+ .set_index("year")["EXCHANGE"]
168
+ )
169
+
170
+ # Apply France's exchange rates to rows with entity_code == 998 and matching year
171
+ df.loc[df.entity_code == 998, "EXCHANGE"] = df.loc[
172
+ df.entity_code == 998, "year"
173
+ ].map(eur)
174
+
175
+ return df
176
+
177
+
150
178
  def download_weo() -> None:
151
179
  """Download the WEO data, process it, and save it to a parquet file."""
152
180
  logger.info("Downloading the latest WEO data...")
@@ -161,6 +189,7 @@ def download_weo() -> None:
161
189
  .pipe(_compute_exchange)
162
190
  .pipe(add_pydeflate_iso3, column="entity", from_type="regex")
163
191
  .pipe(_pivot_concept_code)
192
+ .pipe(_create_eur_series)
164
193
  .pipe(compute_exchange_deflator, base_year_measure="NGDP_D")
165
194
  .pipe(prefix_pydeflate_to_columns)
166
195
  .pipe(enforce_pyarrow_types)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pydeflate"
3
- version = "2.1.2"
3
+ version = "2.1.3"
4
4
  description = "Package to convert current prices figures to constant prices and vice versa"
5
5
  authors = [
6
6
  {name = "Jorge Rivera",email = "jorge.rivera@one.org"}
File without changes
File without changes
File without changes