Keep the most specific DateIn and DateOut instead of coarsening to years

Aperta
#342 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
numpy, pandas, python
Ambito
data

Direzione di ricerca

Start by reading the loaders named in the issue (MASTR, GND, GEO) where full dates are reduced to years, then aggregate_units and reduce_matched_dataframe, which aggregate DateIn/DateOut as numeric years. The storage model is an open question, so settle whether DateIn/DateOut become reduced-precision ISO strings or gain companion columns before editing; that choice drives the loader and aggregation changes. Done means the mixed year/full-date example no longer raises and agreeing sources keep the most specific date, with tests for the chosen schema.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

DateIn and DateOut are years. Some data sources give full dates, but only the year is kept. The matching cannot combine a year with a full date.

Models like PyPSA-Eur must then pick a convention, such as 1 January or 31 December. For a plant commissioned mid-year, both are wrong by months.

Example

import numpy as np
import pandas as pd
import powerplantmatching as pm
from powerplantmatching.matching import reduce_matched_dataframe

config = pm.get_config()
columns = pd.MultiIndex.from_product([config["target_columns"], ["GEM", "MASTR"]])
df = pd.DataFrame(np.nan, index=[0], columns=columns, dtype=object)
df["Name"] = "Kraftwerk Musterstadt"

# source A gives a year, source B gives a full date
df.loc[0, "DateIn"] = [2026, pd.Timestamp("2026-11-17")]
reduce_matched_dataframe(df, config=config)
# TypeError: agg function failed [how->min,dtype->object]

Where the information is lost

  • Loaders parse full dates and keep the year, e.g. pd.to_datetime(...).dt.year in MASTR and GND, or the first four characters in GEO.
  • aggregate_units and reduce_matched_dataframe take the minimum DateIn and the maximum DateOut, which assumes numeric years.

Proposal

  1. Loaders keep the date as specific as the source gives it (maybe picking a convention for annual resolution values is necessary).
  2. If matched sources agree on the year, use the most specific date.

Open question: storage

  • Reuse DateIn and DateOut, e.g. as ISO 8601 strings with reduced precision (2026 or 2026-11-17) or as dates with a precision column. Slightly breaking for numeric filters such as DateIn < 2026.
  • Add columns for the full date and keep DateIn and DateOut as years. Not breaking, but two columns per date.
Lingua principale
Python
Stelle
237
Fork
79
Merge medio
2g 21h
PR unite (30g)
8

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PyPSA/powerplantmatching

Tutte le issue di PyPSA/powerplantmatching

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.