From 7a65d414de5ae52e446f5dc55982e230a953d1af Mon Sep 17 00:00:00 2001 From: Fridolin Glatter Date: Fri, 20 Dec 2024 14:05:19 +0100 Subject: [PATCH] Use getattr to DRY some lines --- ixmp4/data/db/optimization/table/model.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/ixmp4/data/db/optimization/table/model.py b/ixmp4/data/db/optimization/table/model.py index 56e61020..8c8396ea 100644 --- a/ixmp4/data/db/optimization/table/model.py +++ b/ixmp4/data/db/optimization/table/model.py @@ -81,23 +81,7 @@ def data(self) -> dict[str, list[float] | list[int] | list[str]]: dict[str, list[float] | list[int] | list[str]], pd.DataFrame.from_records( [ - { - "Column 0": td.value_0, - "Column 1": td.value_1, - "Column 2": td.value_2, - "Column 3": td.value_3, - "Column 4": td.value_4, - "Column 5": td.value_5, - "Column 6": td.value_6, - "Column 7": td.value_7, - "Column 8": td.value_8, - "Column 9": td.value_9, - "Column 10": td.value_10, - "Column 11": td.value_11, - "Column 12": td.value_12, - "Column 13": td.value_13, - "Column 14": td.value_14, - } + {f"Column {i}": getattr(td, f"value_{i}") for i in range(15)} for td in self._data ] )