Skip to content

Commit

Permalink
Merge pull request #158 from trevorb1/pandas-2.0
Browse files Browse the repository at this point in the history
Upgrade to Pandas 2.0
  • Loading branch information
trevorb1 authored Apr 16, 2023
2 parents d267381 + b65b8ae commit 7952254
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/citation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: cffconvert

on:
push:
paths:
- citation.cff

jobs:
validate:
name: "validate"
runs-on: ubuntu-latest
steps:
- name: Check out a copy of the repository
uses: actions/checkout@v2

- name: Check whether the citation metadata from CITATION.cff is valid
uses: citation-file-format/[email protected]
with:
args: "--validate"
4 changes: 2 additions & 2 deletions citation.cff → CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ authors:
orcid: https://orcid.org/0000-0001-8144-5260
title: "otoole: OSeMOSYS tools for energy work"
version: 1.0.0
doi: 10.5281/zenodo.4730003
date-released: 2021-04-30
doi: 10.5281/zenodo.7677990
date-released: 2023-02-26
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ importlib_resources; python_version<'3.7'
networkx
openpyxl
pandas
pandas_datapackage_reader
pydantic
pydot
pyyaml
Expand Down
1 change: 1 addition & 0 deletions src/otoole/results/result_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ def discount_factor(
if regions and years:
discount_rate["YEAR"] = [years]
discount_factor = discount_rate.explode("YEAR").reset_index(level="REGION")
discount_factor["YEAR"] = discount_factor["YEAR"].astype(int)
discount_factor["NUM"] = discount_factor["YEAR"] - discount_factor["YEAR"].min()
discount_factor["RATE"] = discount_factor["VALUE"] + 1
discount_factor["VALUE"] = (
Expand Down
4 changes: 2 additions & 2 deletions src/otoole/results/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _convert_to_dataframe(self, file_path: Union[str, TextIO]) -> pd.DataFrame:
skiprows=2,
) # type: pd.DataFrame
df[["Variable", "Index"]] = df["Variable"].str.split("(", expand=True)
df["Index"] = df["Index"].str.replace(")", "", regex=True)
df["Index"] = df["Index"].str.replace(")", "")
LOGGER.debug(df)
df = df[(df["Value"] != 0)].reset_index()
return df[["Variable", "Index", "Value"]].astype({"Value": float})
Expand Down Expand Up @@ -325,6 +325,6 @@ def _convert_to_dataframe(self, file_path: Union[str, TextIO]) -> pd.DataFrame:
.str.split(expand=True)[1]
)
df[["Index", "Value"]] = df["indexvalue"].str.split(expand=True).loc[:, 0:1]
df["Index"] = df["Index"].str.replace(")", "", regex=True)
df["Index"] = df["Index"].str.replace(")", "")
df = df.drop(columns=["indexvalue"])
return df[["Variable", "Index", "Value"]].astype({"Value": float})

0 comments on commit 7952254

Please sign in to comment.