From 54d9c637a8a7014c7f8e249cb39dd0674152a765 Mon Sep 17 00:00:00 2001 From: liniiiiii Date: Wed, 22 Jan 2025 10:41:11 +0100 Subject: [PATCH] update the termnology --- .../{EUR_convert.py => convert_currency_EUR.py} | 8 +++----- Database/scr/normalize_currency.py | 14 ++++++-------- releases/README.md | 4 ++-- 3 files changed, 11 insertions(+), 15 deletions(-) rename Database/{EUR_convert.py => convert_currency_EUR.py} (88%) diff --git a/Database/EUR_convert.py b/Database/convert_currency_EUR.py similarity index 88% rename from Database/EUR_convert.py rename to Database/convert_currency_EUR.py index ca168d7c3..0efae7f60 100644 --- a/Database/EUR_convert.py +++ b/Database/convert_currency_EUR.py @@ -36,16 +36,14 @@ logger.info("Converting USD to EUR") for cat in ia_utils.monetary_categories: logger.info(f"Converting currencies in L1 for category {cat}") - l1 = l1.apply( - lambda x: cc_utils.Lasted_Year_USD_Inflated_to_EUR(x, l1_impact=cat, level="l1", impact=cat), axis=1 - ) + l1 = l1.apply(lambda x: cc_utils.Convert_USD_to_EUR(x, l1_impact=cat, level="l1", impact=cat), axis=1) logger.info(f"Converting currencies in L2 for category {cat}") l2[cat] = l2[cat].apply( - lambda x: cc_utils.Lasted_Year_USD_Inflated_to_EUR(x, l1_impact=None, level="l2", impact=cat), axis=1 + lambda x: cc_utils.Convert_USD_to_EUR(x, l1_impact=None, level="l2", impact=cat), axis=1 ) logger.info(f"Converting currencies in L3 for category {cat}") l3[cat] = l3[cat].apply( - lambda x: cc_utils.Lasted_Year_USD_Inflated_to_EUR(x, l1_impact=None, level="l3", impact=cat), axis=1 + lambda x: cc_utils.Convert_USD_to_EUR(x, l1_impact=None, level="l3", impact=cat), axis=1 ) logger.info(f"Storing results in {args.output_dir}") diff --git a/Database/scr/normalize_currency.py b/Database/scr/normalize_currency.py index a6a454eab..e69dd109f 100644 --- a/Database/scr/normalize_currency.py +++ b/Database/scr/normalize_currency.py @@ -238,8 +238,8 @@ def convert_to_USD_yearly_avg( ) return amount - # only provide EUR in lastest year in the database - def convert_USD_to_EUR_latest_year_avg( + # only provide EUR in inflation year in the database + def normalize_row_EUR_inflation_year( self, currency: str, amount: float, year: int, event_id: str, level: str, impact: str ): try: @@ -254,7 +254,7 @@ def convert_USD_to_EUR_latest_year_avg( ), f"Amount is missing or invalid: '{amount}' of type '{type(amount)}'" assert currency, "Currency is missing" - # always use the lastest year of EUR-USD conversion rate + # always use the inflation year of EUR-USD conversion rate # extract rate rate = ( self.currency_conversion_yearly_avg[self.eur] @@ -351,9 +351,7 @@ def normalize_row_USD(self, row: pd.DataFrame, l1_impact: None | str, level: str self.logger.info(f"Could not convert to USD since no year can be inferred. Row: {dict(row)}") return row - def Lasted_Year_USD_Inflated_to_EUR( - self, row: pd.DataFrame, l1_impact: None | str, level: str, impact: str - ) -> pd.DataFrame: + def Convert_USD_to_EUR(self, row: pd.DataFrame, l1_impact: None | str, level: str, impact: str) -> pd.DataFrame: num_min, num_max, num_unit, num_approx, num_inflation_adjusted, num_inflation_adjusted_year = ( self.num_min, self.num_max, @@ -382,10 +380,10 @@ def Lasted_Year_USD_Inflated_to_EUR( if year: if row[num_unit] == self.usd: - row[num_min] = self.convert_USD_to_EUR_latest_year_avg( + row[num_min] = self.normalize_row_EUR_inflation_year( row[num_unit], row[num_min], year=year, event_id=row[self.event_id], level=level, impact=impact ) - row[num_max] = self.convert_USD_to_EUR_latest_year_avg( + row[num_max] = self.normalize_row_EUR_inflation_year( row[num_unit], row[num_max], year=year, event_id=row[self.event_id], level=level, impact=impact ) row[num_approx] = 1 # adjusted value are all approximations diff --git a/releases/README.md b/releases/README.md index 930c0e92f..6e7a522f9 100644 --- a/releases/README.md +++ b/releases/README.md @@ -18,8 +18,8 @@ | [releases/impactdb.v1.0.dg_filled.db](releases/impactdb.v1.0.dg_filled.db) | A **post-processed** database after applying a final layer of post-processing, excluding the handling of currencies and inflation adjustment (has missing validation rules) | | [releases/impactdb.v1.1.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) | A **post-processed** database after applying a final layer of post-processing, including the handling of currencies and inflation adjustment. In this release, end years of events are nullable. | -| [releases/impactdb.v1.2.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) **Lastest 2024 USD version** | A **post-processed** database that improves on [releases/impactdb.v1.1.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) by removing events that have no L1/L2/L3 impacts (ie. all impact data in L1 is NULL), most currencies are converted to USD in the database and inflated to 2024 value. | -| [releases/impactdb.v1.3.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) **Lastest 2024 EUR version** | A **post-processed** database that convert 2024 USD to 2024 EUR on [releases/impactdb.v1.2.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) by using a constant conversion rate in 2024 | +| [releases/impactdb.v1.2.dg_filled.db](releases/impactdb.v1.2.dg_filled.db) **Inflation to 2024 USD version** | A **post-processed** database that improves on [releases/impactdb.v1.1.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) by removing events that have no L1/L2/L3 impacts (ie. all impact data in L1 is NULL), most currencies are converted to USD in the database and inflated to 2024 value. | +| [releases/impactdb.v1.3.dg_filled.db](releases/impactdb.v1.3.dg_filled.db) **Inflation to 2024 EUR version** | A **post-processed** database that convert 2024 USD to 2024 EUR on [releases/impactdb.v1.2.dg_filled.db](releases/impactdb.v1.1.dg_filled.db) by using a constant conversion rate in 2024 | ### Additional files and metadata | File | Description |