From 3879df7a097b063a5bf24238fd1c81f87fdda1d9 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 29 Jun 2023 15:31:25 +0200 Subject: [PATCH] build_monthly_prices: adress warnings --- scripts/build_monthly_prices.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/build_monthly_prices.py b/scripts/build_monthly_prices.py index baf15b4f..939f99ee 100644 --- a/scripts/build_monthly_prices.py +++ b/scripts/build_monthly_prices.py @@ -84,16 +84,14 @@ def get_fuel_price(): def extract_df(sheet, keyword): # Create a DatetimeIndex for the first day of each month of a given year - dti = pd.date_range( + month_list = pd.date_range( start=f"{validation_year}-01-01", end=f"{validation_year}-12-01", freq="MS" - ) - # Extract month names - month_list = dti.month + ).month start = fuel_price[sheet].index[(fuel_price[sheet] == keyword).any(axis=1)] - df = fuel_price[sheet].loc[start[0] : start[0] + 18, :] - df.dropna(axis=0, inplace=True) - df.iloc[:, 0] = df.iloc[:, 0].apply(lambda x: int(x.replace(" ...", ""))) + df = fuel_price[sheet].loc[start[0] : start[0] + 18] + df = df.dropna(axis=0) df.set_index(df.columns[0], inplace=True) + df.index = df.index.map(lambda x: int(x.replace(" ...", ""))) df = df.iloc[:, :12] df.columns = month_list return df