address recent deprecations (#235)

* address recent deprecations

* address recent deprecations in pd.read_csv
This commit is contained in:
Fabian Neumann 2022-04-12 14:37:05 +02:00 committed by GitHub
parent 6ed92475c9
commit 1625d9db75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 16 deletions

View File

@ -153,8 +153,8 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
df_agg.Fueltype = df_agg.Fueltype.map(rename_fuel)
# assign clustered bus
busmap_s = pd.read_csv(snakemake.input.busmap_s, index_col=0, squeeze=True)
busmap = pd.read_csv(snakemake.input.busmap, index_col=0, squeeze=True)
busmap_s = pd.read_csv(snakemake.input.busmap_s, index_col=0).squeeze()
busmap = pd.read_csv(snakemake.input.busmap, index_col=0).squeeze()
inv_busmap = {}
for k, v in busmap.iteritems():

View File

@ -149,7 +149,7 @@ def build_nuts2_shapes():
nuts2.rename(index={"ME00": "ME", "MK00": "MK"}, inplace=True)
return nuts2.append(missing)
return pd.concat([nuts2, missing])
def area(gdf):

View File

@ -26,7 +26,7 @@ def build_gas_input_locations(lng_fn, planned_lng_fn, entry_fn, prod_fn, countri
planned_lng = pd.read_csv(planned_lng_fn)
planned_lng.geometry = planned_lng.geometry.apply(wkt.loads)
planned_lng = gpd.GeoDataFrame(planned_lng, crs=4326)
lng = lng.append(planned_lng, ignore_index=True)
lng = pd.concat([lng, planned_lng], ignore_index=True)
# Entry points from outside the model scope
entry = read_scigrid_gas(entry_fn)

View File

@ -115,14 +115,14 @@ def get_energy_ratio(country):
# estimate physical output, energy consumption in the sector and country
fn = f"{eurostat_dir}/{eb_names[country]}.XLSX"
df = pd.read_excel(fn, sheet_name='2016', index_col=2,
header=0, skiprows=1, squeeze=True)
header=0, skiprows=1).squeeze('columns')
e_country = df.loc[eb_sectors.keys(
), 'Total all products'].rename(eb_sectors)
fn = f'{jrc_dir}/JRC-IDEES-2015_Industry_EU28.xlsx'
df = pd.read_excel(fn, sheet_name='Ind_Summary',
index_col=0, header=0, squeeze=True)
index_col=0, header=0).squeeze('columns')
assert df.index[48] == "by sector"
year_i = df.columns.get_loc(year)
@ -142,7 +142,7 @@ def industry_production_per_country(country):
fn = f'{jrc_dir}/JRC-IDEES-2015_Industry_{jrc_country}.xlsx'
sheet = sub_sheet_name_dict[sector]
df = pd.read_excel(fn, sheet_name=sheet,
index_col=0, header=0, squeeze=True)
index_col=0, header=0).squeeze('columns')
year_i = df.columns.get_loc(year)
df = df.iloc[find_physical_output(df), year_i]

View File

@ -78,9 +78,8 @@ def load_idees_data(sector, country="EU28"):
sheet_name=list(sheets.values()),
index_col=0,
header=0,
squeeze=True,
usecols=usecols,
)
).squeeze('columns')
for k, v in sheets.items():
idees[k] = idees.pop(v)

View File

@ -33,7 +33,7 @@ if __name__ == '__main__':
urban_fraction = pd.read_csv(snakemake.input.urban_percent,
header=None, index_col=0,
names=['fraction'], squeeze=True) / 100.
names=['fraction']).squeeze() / 100.
# fill missing Balkans values
missing = ["AL", "ME", "MK"]

View File

@ -279,7 +279,7 @@ def create_network_topology(n, prefix, carriers=["DC"], connector=" -> ", bidire
topo_reverse = topo.copy()
topo_reverse.rename(columns=swap_buses, inplace=True)
topo_reverse.index = topo_reverse.apply(make_index, axis=1)
topo = topo.append(topo_reverse)
topo = pd.concat([topo, topo_reverse])
return topo
@ -686,7 +686,7 @@ def prepare_data(n):
## Get overall demand curve for all vehicles
traffic = pd.read_csv(snakemake.input.traffic_data_KFZ, skiprows=2, usecols=["count"], squeeze=True)
traffic = pd.read_csv(snakemake.input.traffic_data_KFZ, skiprows=2, usecols=["count"]).squeeze()
#Generate profiles
transport_shape = generate_periodic_profiles(
@ -741,7 +741,7 @@ def prepare_data(n):
## derive plugged-in availability for PKW's (cars)
traffic = pd.read_csv(snakemake.input.traffic_data_Pkw, skiprows=2, usecols=["count"], squeeze=True)
traffic = pd.read_csv(snakemake.input.traffic_data_Pkw, skiprows=2, usecols=["count"]).squeeze()
avail_max = options.get("bev_avail_max", 0.95)
avail_mean = options.get("bev_avail_mean", 0.8)
@ -1888,8 +1888,7 @@ def add_biomass(n, costs):
transport_costs = pd.read_csv(
snakemake.input.biomass_transport_costs,
index_col=0,
squeeze=True
)
).squeeze()
# add biomass transport
biomass_transport = create_network_topology(n, "biomass transport ", bidirectional=False)
@ -2521,7 +2520,7 @@ if __name__ == "__main__":
fn = snakemake.config['results_dir'] + snakemake.config['run'] + '/csvs/carbon_budget_distribution.csv'
if not os.path.exists(fn):
build_carbon_budget(o, fn)
co2_cap = pd.read_csv(fn, index_col=0, squeeze=True)
co2_cap = pd.read_csv(fn, index_col=0).squeeze()
limit = co2_cap[investment_year]
break
for o in opts: