From b72da76b04c6dbf9bdb94a18bd91192e9c390321 Mon Sep 17 00:00:00 2001 From: Manuel Schlund <32543114+schlunma@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:11:03 +0100 Subject: [PATCH] Pin pandas to avoid broken `round` function (#2305) Co-authored-by: Valeriu Predoi --- environment.yml | 2 +- esmvalcore/cmor/_fixes/icon/icon.py | 5 ++--- setup.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/environment.yml b/environment.yml index 93582e968c..70923cf1a9 100644 --- a/environment.yml +++ b/environment.yml @@ -30,7 +30,7 @@ dependencies: - netcdf4 - numpy !=1.24.3 - packaging - - pandas + - pandas !=2.2.0 # github.com/ESMValGroup/ESMValCore/pull/2305 - pillow - pip !=21.3 - prov diff --git a/esmvalcore/cmor/_fixes/icon/icon.py b/esmvalcore/cmor/_fixes/icon/icon.py index 214cb6e99f..2e1dfd3bb3 100644 --- a/esmvalcore/cmor/_fixes/icon/icon.py +++ b/esmvalcore/cmor/_fixes/icon/icon.py @@ -492,9 +492,8 @@ def _fix_invalid_time_units(time_coord): # it to correct units. Note: we also round to next second, otherwise # this results in times that are off by 1s (e.g., 13:59:59 instead of # 14:00:00). - new_datetimes = (year_month_day + day_float).round( - 'S' - ).dt.to_pydatetime() + rounded_datetimes = (year_month_day + day_float).round('s') + new_datetimes = np.array(rounded_datetimes.dt.to_pydatetime()) new_dt_points = date2num(np.array(new_datetimes), new_t_units) # Modify time coordinate in place diff --git a/setup.py b/setup.py index f8c3e28550..10117035f6 100755 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ 'netCDF4', 'numpy!=1.24.3', 'packaging', - 'pandas', + 'pandas!=2.2.0', # github.com/ESMValGroup/ESMValCore/pull/2305 'pillow', 'prov', 'psutil',