Skip to content

Commit ebbe3c2

Browse files
committed
fix future warnings
1 parent 8f9a93b commit ebbe3c2

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

scripts/compile_cost_assumptions.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,16 @@ def get_data_DEA(tech, data_in, expectation=None):
360360
# replace missing data
361361
df.replace("-", np.nan, inplace=True)
362362
# average data in format "lower_value-upper_value"
363-
df = df.applymap(lambda x: (float((x).split("-")[0])
364-
+ float((x).split("-")[1]))/2 if (type(x)==str and "-" in x) else x)
363+
df = df.apply(lambda row: row.apply(lambda x: (float(x.split("-")[0])
364+
+ float(x.split("-")[1]))
365+
/ 2 if isinstance(x, str) and "-" in x else x),
366+
axis=1)
367+
365368
# remove symbols "~", ">", "<" and " "
366369
for sym in ["~", ">", "<", " "]:
367-
df = df.applymap(lambda x: x.replace(sym,"") if type(x)==str else x)
370+
df = df.apply(lambda col: col.apply(lambda x: x.replace(sym, "")
371+
if isinstance(x, str) else x))
372+
368373

369374
df = df.astype(float)
370375
df = df.mask(df.apply(pd.to_numeric, errors='coerce').isnull(), df.astype(str).apply(lambda x: x.str.strip()))
@@ -436,7 +441,7 @@ def get_data_DEA(tech, data_in, expectation=None):
436441
df_final.loc[index, :] = values
437442

438443
# if year-specific data is missing and not fixed by interpolation fill forward with same values
439-
df_final = df_final.fillna(method='ffill', axis=1)
444+
df_final = df_final.ffill(axis=1)
440445

441446
df_final["source"] = source_dict["DEA"] + ", " + excel_file.replace("inputs/","")
442447
if tech in new_format and (tech!="electrolysis"):
@@ -773,6 +778,7 @@ def clean_up_units(tech_data, value_column="", source=""):
773778
"MW": "MW_e"}))
774779

775780
if "methanolisation" in tech_data.index:
781+
tech_data = tech_data.sort_index()
776782
tech_data.loc[('methanolisation', 'Variable O&M'), "unit"] = "EUR/MWh_MeOH"
777783

778784
return tech_data
@@ -945,7 +951,7 @@ def order_data(tech_data):
945951
if len(investment):
946952
fixed = df[(df.index.str.contains("Fixed O&M") |
947953
df.index.str.contains("Total O&M")) &
948-
((df.unit==investment.unit[0]+"/year")|
954+
((df.unit==investment.unit.iloc[0]+"/year")|
949955
(df.unit=="EUR/MW/km/year")|
950956
(df.unit=="EUR/MW/year")|
951957
(df.unit=="EUR/MW_e/y, 2020")|
@@ -954,7 +960,7 @@ def order_data(tech_data):
954960
(df.unit=="EUR/MW_MeOH/year")|
955961
(df.unit=="EUR/MW_CH4/year")|
956962
(df.unit=='% of specific investment/year')|
957-
(df.unit==investment.unit.str.split(" ")[0][0]+"/year"))].copy()
963+
(df.unit==investment.unit.str.split(" ").iloc[0][0]+"/year"))].copy()
958964
if (len(fixed)!=1) and (len(df[df.index.str.contains("Fixed O&M")])!=0):
959965
switch = True
960966
print("check FOM: ", tech, " ",
@@ -1165,7 +1171,7 @@ def add_gas_storage(data):
11651171
gas_storage.dropna(axis=1, how="all", inplace=True)
11661172

11671173
# establishment of one cavern ~ 100*1e6 Nm3 = 1.1 TWh
1168-
investment = gas_storage.loc['Total cost, 100 mio Nm3 active volume'][0]
1174+
investment = gas_storage.loc['Total cost, 100 mio Nm3 active volume'].iloc[0]
11691175
# convert million EUR/1.1 TWh -> EUR/kWh
11701176
investment /= (1.1 * 1e3)
11711177
data.loc[("gas storage", "investment"), years] = investment
@@ -2101,7 +2107,7 @@ def geometric_series(nominator, denominator=1, number_of_terms=1, start=1):
21012107
# rename + reorder to fit to other data
21022108
costs_vehicles = rename_ISE_vehicles(costs_vehicles)
21032109
if 'NT' in costs_vehicles.index:
2104-
costs_vehicles.drop(['NT'], axis=0, inplace=True)
2110+
costs_vehicles.drop(['NT'], axis=0, inplace=True, level=0)
21052111
costs_vehicles = convert_units(costs_vehicles)
21062112
# add costs for vehicles
21072113
data = pd.concat([data, costs_vehicles], sort=True)

0 commit comments

Comments
 (0)