From 4082f9b953f0f2d684f0e06d77bb7cba3ff18fbb Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 3 Mar 2023 10:07:04 -0500 Subject: [PATCH 1/9] fixes for pandas 2.0.0 compatibility --- rdtools/degradation.py | 6 +++--- rdtools/filtering.py | 7 +++---- rdtools/test/availability_test.py | 2 +- rdtools/test/degradation_test.py | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/rdtools/degradation.py b/rdtools/degradation.py index 7a6bee70..b97bc519 100644 --- a/rdtools/degradation.py +++ b/rdtools/degradation.py @@ -36,7 +36,7 @@ def degradation_ols(energy_normalized, confidence_level=68.2): # calculate a years column as x value for regression, ignoring leap years day_diffs = (df.index - df.index[0]) - df['days'] = day_diffs.astype('timedelta64[s]') / (60 * 60 * 24) + df['days'] = day_diffs / pd.Timedelta('1d') df['years'] = df.days / 365.0 # add intercept-constant to the exogeneous variable @@ -121,7 +121,7 @@ def degradation_classical_decomposition(energy_normalized, # calculate a years column as x value for regression, ignoring leap years day_diffs = (df.index - df.index[0]) - df['days'] = day_diffs.astype('timedelta64[s]') / (60 * 60 * 24) + df['days'] = day_diffs / pd.Timedelta('1d') df['years'] = df.days / 365.0 # Compute yearly rolling mean to isolate trend component using @@ -266,7 +266,7 @@ def degradation_year_on_year(energy_normalized, recenter=True, tolerance=pd.Timedelta('8D') ) - df['time_diff_years'] = (df.dt - df.dt_right).astype('timedelta64[h]') / 8760.0 + df['time_diff_years'] = (df.dt - df.dt_right) / pd.Timedelta('365d') df['yoy'] = 100.0 * (df.energy - df.energy_right) / (df.time_diff_years) df.index = df.dt diff --git a/rdtools/filtering.py b/rdtools/filtering.py index c72f0667..783f76fa 100644 --- a/rdtools/filtering.py +++ b/rdtools/filtering.py @@ -424,8 +424,8 @@ def logic_clip_filter(power_ac, # series sampling frequency is less than 95% consistent. _check_data_sampling_frequency(power_ac) # Get the sampling frequency of the time series - time_series_sampling_frequency = power_ac.index.to_series().diff()\ - .astype('timedelta64[m]').mode()[0] + time_series_sampling_frequency = (power_ac.index.to_series().diff() + / pd.Timedelta('60s')).mode()[0] # Make copies of the original inputs for the cases that the data is # changes for clipping evaluation original_time_series_sampling_frequency = time_series_sampling_frequency @@ -651,8 +651,7 @@ def xgboost_clip_filter(power_ac, # series sampling frequency is less than 95% consistent. _check_data_sampling_frequency(power_ac) # Get the most common sampling frequency - sampling_frequency = int(power_ac.index.to_series().diff() - .astype('timedelta64[m]').mode()[0]) + sampling_frequency = int((power_ac.index.to_series().diff() / pd.Timedelta('60s')).mode()[0]) freq_string = str(sampling_frequency) + "T" # Min-max normalize # Resample the series based on the most common sampling frequency diff --git a/rdtools/test/availability_test.py b/rdtools/test/availability_test.py index 7197608f..2b6608c2 100644 --- a/rdtools/test/availability_test.py +++ b/rdtools/test/availability_test.py @@ -162,7 +162,7 @@ def difficult_data(): # generate a plausible clear-sky power signal times = pd.date_range('2019-01-01', '2019-01-06', freq='15min', - tz='US/Eastern', closed='left') + tz='US/Eastern') location = pvlib.location.Location(40, -80) clearsky = location.get_clearsky(times, model='haurwitz') # just scale GHI to power for simplicity diff --git a/rdtools/test/degradation_test.py b/rdtools/test/degradation_test.py index 9bfb1e6c..a66e4cdd 100644 --- a/rdtools/test/degradation_test.py +++ b/rdtools/test/degradation_test.py @@ -34,7 +34,7 @@ def get_corr_energy(cls, rd, input_freq): freq = input_freq x = pd.date_range(start=start, end=end, freq=freq) - day_deltas = (x - x[0]).astype('timedelta64[s]') / (60.0 * 60.0 * 24) + day_deltas = (x - x[0]) / pd.Timedelta('1d') noise = (np.random.rand(len(day_deltas)) - 0.5) / 1e3 y = 1 + daily_rd * day_deltas + noise From 2dd021727af08e82cc8e21320e05e6dabd752fac Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 3 Mar 2023 10:15:08 -0500 Subject: [PATCH 2/9] lint --- rdtools/filtering.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rdtools/filtering.py b/rdtools/filtering.py index 783f76fa..1fa662f6 100644 --- a/rdtools/filtering.py +++ b/rdtools/filtering.py @@ -424,8 +424,9 @@ def logic_clip_filter(power_ac, # series sampling frequency is less than 95% consistent. _check_data_sampling_frequency(power_ac) # Get the sampling frequency of the time series - time_series_sampling_frequency = (power_ac.index.to_series().diff() - / pd.Timedelta('60s')).mode()[0] + time_series_sampling_frequency = ( + power_ac.index.to_series().diff() / pd.Timedelta('60s') + ).mode()[0] # Make copies of the original inputs for the cases that the data is # changes for clipping evaluation original_time_series_sampling_frequency = time_series_sampling_frequency From 14137eef7222a1d30fdbd835ba5eb0d31dcd0961 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 3 Mar 2023 10:18:32 -0500 Subject: [PATCH 3/9] temporarily add a pandas==2.0.0rc0 job --- .github/workflows/pytest.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 257514e4..2ce5d2ad 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -18,7 +18,9 @@ jobs: env: [ '-r requirements.txt .[test]', '-r requirements-min.txt .[test]', - '--upgrade --upgrade-strategy=eager .[test]' + '--upgrade --upgrade-strategy=eager .[test]', + '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0', + ] exclude: - python-version: 3.8 @@ -30,6 +32,9 @@ jobs: # required numpy is not available on python 3.7, so exclude: - python-version: 3.7 env: '-r requirements.txt .[test]' + # no pandas 2.0.0rc0 for py3.7 + - python-version: 3.7 + env: '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0', steps: - uses: actions/checkout@v2 From 1a416f88ed33950d0db5cb947b3363a6daaf8c19 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 3 Mar 2023 10:22:21 -0500 Subject: [PATCH 4/9] fix broken yaml --- .github/workflows/pytest.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 2ce5d2ad..15502303 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -19,8 +19,7 @@ jobs: '-r requirements.txt .[test]', '-r requirements-min.txt .[test]', '--upgrade --upgrade-strategy=eager .[test]', - '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0', - + '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0' ] exclude: - python-version: 3.8 @@ -34,7 +33,7 @@ jobs: env: '-r requirements.txt .[test]' # no pandas 2.0.0rc0 for py3.7 - python-version: 3.7 - env: '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0', + env: '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0' steps: - uses: actions/checkout@v2 From 94736144c0afafab26367991ec3284b711cbd8f3 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 3 Mar 2023 15:34:53 -0500 Subject: [PATCH 5/9] pin nbval for semicolon suppression issue --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 12951aa0..cf0aed36 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ 'pytest >= 3.6.3', 'coverage', 'flake8', - 'nbval', + 'nbval==0.9.6', # https://github.com/computationalmodelling/nbval/issues/194 'pytest-mock', ] From c91defb0147135e8e3023dd8bcb2c6c633d8ce66 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 3 Mar 2023 15:58:32 -0500 Subject: [PATCH 6/9] lint --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cf0aed36..a396b793 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ 'pytest >= 3.6.3', 'coverage', 'flake8', - 'nbval==0.9.6', # https://github.com/computationalmodelling/nbval/issues/194 + 'nbval==0.9.6', # https://github.com/computationalmodelling/nbval/issues/194 'pytest-mock', ] From 29a7ae90fa6ecc5a44f33c4d8f2ff147110f0126 Mon Sep 17 00:00:00 2001 From: Michael Deceglie Date: Wed, 26 Apr 2023 17:19:33 -0600 Subject: [PATCH 7/9] remove pandas 2.0.0rc0 job --- .github/workflows/pytest.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 15502303..c0cb5cb7 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -18,8 +18,7 @@ jobs: env: [ '-r requirements.txt .[test]', '-r requirements-min.txt .[test]', - '--upgrade --upgrade-strategy=eager .[test]', - '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0' + '--upgrade --upgrade-strategy=eager .[test]' ] exclude: - python-version: 3.8 @@ -31,9 +30,6 @@ jobs: # required numpy is not available on python 3.7, so exclude: - python-version: 3.7 env: '-r requirements.txt .[test]' - # no pandas 2.0.0rc0 for py3.7 - - python-version: 3.7 - env: '--upgrade --upgrade-strategy=eager .[test] pandas==2.0.0rc0' steps: - uses: actions/checkout@v2 @@ -47,4 +43,4 @@ jobs: pip install ${{ matrix.env }} - name: Test with pytest ${{ matrix.env }} run: | - pytest \ No newline at end of file + pytest From f523cd229f43cf417c2dac7dc57b4d53d5da764a Mon Sep 17 00:00:00 2001 From: Michael Deceglie Date: Wed, 26 Apr 2023 20:05:20 -0600 Subject: [PATCH 8/9] change log --- docs/sphinx/source/changelog.rst | 1 + docs/sphinx/source/changelog/v2.1.5.rst | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 docs/sphinx/source/changelog/v2.1.5.rst diff --git a/docs/sphinx/source/changelog.rst b/docs/sphinx/source/changelog.rst index 3daa0938..2248c8f7 100644 --- a/docs/sphinx/source/changelog.rst +++ b/docs/sphinx/source/changelog.rst @@ -1,5 +1,6 @@ RdTools Change Log ================== +.. include:: changelog/v2.1.5.rst .. include:: changelog/v2.1.4.rst .. include:: changelog/v2.1.3.rst .. include:: changelog/v2.1.2.rst diff --git a/docs/sphinx/source/changelog/v2.1.5.rst b/docs/sphinx/source/changelog/v2.1.5.rst new file mode 100644 index 00000000..d1b90966 --- /dev/null +++ b/docs/sphinx/source/changelog/v2.1.5.rst @@ -0,0 +1,13 @@ +************************* +v2.1.5 (April 27, 2023) +************************* + +Bug Fixes +--------- +* Add support for pandas 2.0 (:issue:`361`, :pull:`362`) + + +Contributors +------------ +* Kevin Anderson (:ghuser:`kanderso-nrel`) +* Michael Deceglie (:ghuser:`mdeceglie`) From 8aa77337f4f1baecbcde5eaf3fee4f020400d846 Mon Sep 17 00:00:00 2001 From: Michael Deceglie Date: Tue, 16 May 2023 15:36:58 -0600 Subject: [PATCH 9/9] Update change log date --- docs/sphinx/source/changelog/v2.1.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/changelog/v2.1.5.rst b/docs/sphinx/source/changelog/v2.1.5.rst index d1b90966..2cfa8fa3 100644 --- a/docs/sphinx/source/changelog/v2.1.5.rst +++ b/docs/sphinx/source/changelog/v2.1.5.rst @@ -1,5 +1,5 @@ ************************* -v2.1.5 (April 27, 2023) +v2.1.5 (May 16, 2023) ************************* Bug Fixes