From 2bde7359535832f8ce5475499796df085670fa31 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Thu, 25 Jan 2024 15:44:49 +1100 Subject: [PATCH] Pandas now produces a FutureWarning for frequency descriptor 'H'. Use 'h' instead. * nemo/context.py: Use 'h' for hourly frequency ('H' is deprecated). * nemo/nem.py, nemo/sim.py: Likewise. * tests/test_context.py, tests/test_sim.py: Likewise. --- nemo/context.py | 2 +- nemo/nem.py | 2 +- nemo/sim.py | 2 +- tests/test_context.py | 2 +- tests/test_sim.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nemo/context.py b/nemo/context.py index 85047600..986bc9c2 100644 --- a/nemo/context.py +++ b/nemo/context.py @@ -127,7 +127,7 @@ def __str__(self): # constant). Group by the deltas. date_range = pd.date_range(self.unserved.index[0], periods=len(self.unserved.index), - freq='H') + freq='h') deltas = self.unserved.groupby(self.unserved.index - date_range) unserved_events = [k for k, g in deltas] string += 'Number of unserved energy events: ' diff --git a/nemo/nem.py b/nemo/nem.py index 171ff2a2..5c162b25 100644 --- a/nemo/nem.py +++ b/nemo/nem.py @@ -47,7 +47,7 @@ 'demand data must start at midnight' # Calculate hourly demand, averaging half-hours n and n+1. -hourly_regional_demand = demand.resample('H', closed='right').mean() +hourly_regional_demand = demand.resample('h', closed='right').mean() # Now put the demand into polygon resolution according to the load # apportioning figures given in each region's polygons field. diff --git a/nemo/sim.py b/nemo/sim.py index 6256060a..e950a04b 100644 --- a/nemo/sim.py +++ b/nemo/sim.py @@ -135,7 +135,7 @@ def run(context, starthour=None, endhour=None): starthour = context.demand.index.min() if endhour is None: endhour = context.demand.index.max() - date_range = pd.date_range(starthour, endhour, freq='H') + date_range = pd.date_range(starthour, endhour, freq='h') _sim(context, date_range) diff --git a/tests/test_context.py b/tests/test_context.py index eea3fe10..e795a7ee 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -79,7 +79,7 @@ def test_str_with_unserved(self): # Dummy lambda functions for testing self.context.surplus_energy = lambda: 300 self.context.unserved_percent = lambda: 0.5 - rng = pd.date_range(start='2022-01-01', end='2022-01-02', freq='H') + rng = pd.date_range(start='2022-01-01', end='2022-01-02', freq='h') self.context.unserved = pd.Series(index=rng, data=range(len(rng))) output = str(self.context) diff --git a/tests/test_sim.py b/tests/test_sim.py index f44fe40e..49f636ad 100644 --- a/tests/test_sim.py +++ b/tests/test_sim.py @@ -24,7 +24,7 @@ class TestSim(unittest.TestCase): def setUp(self): """Test harness setup.""" self.context = Context() - self.date_range = pd.date_range('2010-01-01', '2010-01-02', freq='H') + self.date_range = pd.date_range('2010-01-01', '2010-01-02', freq='h') self.generation = np.zeros((len(self.date_range), len(self.context.generators))) self.spill = np.zeros((len(self.date_range),