Skip to content

Commit 96f8040

Browse files
committed
use old pandas API for compatibility with Python 3.5
1 parent 201bc08 commit 96f8040

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

aodntools/timeseries_products/hourly_timeseries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def PDresample_by_hour(df, function_dict, function_stats):
310310
df_data = pd.DataFrame(index=pd.DatetimeIndex([]))
311311
for variable in varnames:
312312
ds_var = df[variable]
313-
ds_var_resample = ds_var.resample('1H', offset='30min') # offset centres bin on the hour
313+
ds_var_resample = ds_var.resample('1H', base=0.5) # shift by half hour to centre bin on the hour
314314
ds_var_mean = ds_var_resample.apply(function_dict[variable]).astype(np.float32)
315315
df_data = pd.concat([df_data, ds_var_mean], axis=1, sort=False)
316316
for stat_method in function_stats:
@@ -319,7 +319,7 @@ def PDresample_by_hour(df, function_dict, function_stats):
319319
df_data = pd.concat([df_data, ds_var_stat], axis=1, sort=False)
320320

321321
##forward the index 30min so the timestamps are on the hour
322-
df_data.set_index(df_data.index.shift(30, 'min'), inplace=True)
322+
df_data.index += pd.to_timedelta('30min')
323323

324324
return df_data
325325

0 commit comments

Comments
 (0)