pydeflate 2.1.1__py3-none-any.whl → 2.1.3__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 CHANGED
@@ -1,5 +1,5 @@
1
1
  __author__ = """Jorge Rivera"""
2
- __version__ = "2.1.1"
2
+ __version__ = "2.1.3"
3
3
 
4
4
  from pydeflate.deflate.deflators import (
5
5
  oecd_dac_deflate,
pydeflate/core/api.py CHANGED
@@ -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
@@ -59,7 +59,10 @@ def _match_regex_to_iso3(
59
59
  matches = {}
60
60
 
61
61
  for match in to_match:
62
- match_ = country.get_iso3_country_code_fuzzy(match)[0]
62
+ try:
63
+ match_ = country.get_iso3_country_code_fuzzy(match)[0]
64
+ except:
65
+ match_ = None
63
66
  matches[match] = match_
64
67
  if match_ is None and match not in additional_mapping:
65
68
  logger.debug(f"No ISO3 match found for {match}")
@@ -130,6 +133,7 @@ def add_pydeflate_iso3(
130
133
  not_found=fillna,
131
134
  additional_mapping={
132
135
  "World": "WLD",
136
+ "European Union": "EUR",
133
137
  "EU Institutions": "EUI",
134
138
  "DAC countries": "DAC",
135
139
  "Kosovo": "XXK",
pydeflate/sources/imf.py CHANGED
@@ -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
  Metadata-Version: 2.3
2
2
  Name: pydeflate
3
- Version: 2.1.1
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,7 +1,7 @@
1
1
  pydeflate/.pydeflate_data/README.md,sha256=atNtUL9dD8G184YSd6juFib8TgEQBcSLogiz99APPVs,25
2
- pydeflate/__init__.py,sha256=JJqxQpHXxfqzada3FkaneDTW9BlNM40CBwjJgEZZ4tQ,1013
2
+ pydeflate/__init__.py,sha256=_E54U6FY77A_i2PSCt-oUF0E4EN2GiEpBotw1IQ6fXk,1013
3
3
  pydeflate/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- pydeflate/core/api.py,sha256=mD5zhGlAIvlpT6KcmrHW5rmYwtEq5x2Pqo-jQCQMGpo,14687
4
+ pydeflate/core/api.py,sha256=iB4fLdfnqN_nLLcnMzWtoGksQ6y4sfL0CZsVpiiPGQY,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
@@ -9,17 +9,17 @@ pydeflate/deflate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
9
9
  pydeflate/deflate/deflators.py,sha256=hyLFoX46BAn5m8gTLjw-TFv3x3W6CTQmvmUvq5a_cio,7768
10
10
  pydeflate/deflate/legacy_deflate.py,sha256=9pfqsi5KeWgP1yhXeI6K7bAjUeFY-fmRxrpDB7Zu0zo,3900
11
11
  pydeflate/exchange/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- pydeflate/exchange/exchangers.py,sha256=_3QA3gzUQJgtR6o5n7qrVq8WKLL7x01A8V_DtW8ocPI,6768
12
+ pydeflate/exchange/exchangers.py,sha256=TQ4puU1T2fFQ5gpTP1RUyqJMIXZc1voOyTtS2wj1zrk,6721
13
13
  pydeflate/pydeflate_config.py,sha256=5s4SLJf5is5XcUgJHDRx4f27pPiaVh0H2BL8w9QjW0k,1097
14
14
  pydeflate/settings/emu.json,sha256=BIvbiMUeHUtCESR3sMcBNrS028yp2YraCJdhDJGvAAo,133
15
15
  pydeflate/settings/oecd_codes.json,sha256=jAKI1EgQP4rttjoG3Z-44r1tUJrIEzPCZF5V2aboQhE,911
16
16
  pydeflate/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- pydeflate/sources/common.py,sha256=TvoN3jnqn0xXNuxM52vvgSLA5WRGX8PUD-b5YH6S7GE,9882
17
+ pydeflate/sources/common.py,sha256=zm8fvPES4g1BWzVAGiLX7wMOEfMSdqdeQ_RIm3ucR0E,9978
18
18
  pydeflate/sources/dac.py,sha256=ngFiApGZ_tIQg74ogGVTIbGUA0efnF1SYwfUuqGofOQ,3791
19
- pydeflate/sources/imf.py,sha256=10vc8xhNJvANb7RDD1WFn9oaZ8g53yUV5LxCQCz6ImM,6337
19
+ pydeflate/sources/imf.py,sha256=fuUq_dq_fcxd-bz-VokqPTxEttyFwHunUSEeGDAmGMc,7167
20
20
  pydeflate/sources/world_bank.py,sha256=uMHidFVgEpj1HVUnNhIZV-rV64hsCBV9ZAbYKk6H0Vw,9333
21
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,,
22
+ pydeflate-2.1.3.dist-info/LICENSE,sha256=q5tm9mQxwSbV5Ivvjxs7MMqBgan6DM8I4r4irPvmqZM,1075
23
+ pydeflate-2.1.3.dist-info/METADATA,sha256=uko5SoGA28g70lBi567CZnZ5upLCPk-GShbVHr-G2Ts,12437
24
+ pydeflate-2.1.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
25
+ pydeflate-2.1.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.1
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any