From a8f558079f77156d9cfdfae595236f9cbb0fa4ef Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 22 Feb 2019 15:08:02 +1100 Subject: [PATCH] Export daily means --- waternsw_grabber/waternsw_grabber.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index fd0742a..086abe9 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -258,7 +258,7 @@ def extract_records(input_dir, output_dir, clean_up=False): os.makedirs(output_dir, exist_ok=True) # Create master dataframe - periods = ['all', 'weekly'] + periods = ['all', 'daily', 'weekly'] master = {} for period in periods: master[period] = pd.DataFrame() @@ -315,7 +315,12 @@ def extract_records(input_dir, output_dir, clean_up=False): # Append to master dataframe for period in periods: - if period == 'weekly': + if period == 'daily': + # Resample to daily timestamps + df = df.resample('1d').mean() + df['Date time'] = df.index + + elif period == 'weekly': # Resample to weekly timestamps df = df.resample('1w').mean() df['Date time'] = df.index