def get_sysprice_list(start_time, end_time, frequency='hourly'): '''Wrapper function for creating pandas Series object from data received from the database. Returns: pandas Series object with Elspot daily system prices and corresponding dates for predefined time period. Parameters: start_time - string representing the start of the time period, format must be 'yyyy-mm-dd'. end_time - string representing the end of the time period, format must be 'yyyy-mm-dd'. frequency - string representing the frequency of the output pandas Series object. Currently must be one of ['hourly', 'daily'] ''' #Retrieve hourly system prices and timestamps from database as lists _ , sys_prices, times = get_system_price_volume(start_time, end_time) ts = Series(sys_prices, index=times) if frequency == 'daily': resampling_frequency = 'D' if frequency == 'hourly': #Resampling is not necessary return ts else: return ts.resample(resampling_frequency, how='mean', kind='timestamp')
def get_sysprice_list(start_time, end_time, frequency='hourly'): '''Wrapper function for creating pandas Series object from data received from the database. Returns: pandas Series object with Elspot daily system prices and corresponding dates for predefined time period. Parameters: start_time - string representing the start of the time period, format must be 'yyyy-mm-dd'. end_time - string representing the end of the time period, format must be 'yyyy-mm-dd'. frequency - string representing the frequency of the output pandas Series object. Currently must be one of ['hourly', 'daily'] ''' #Retrieve hourly system prices and timestamps from database as lists _ , sys_prices, times = get_system_price_volume(start_time, end_time) ts = Series(sys_prices, index=times) if frequency == 'daily': resampling_frequency = 'D' '''Weekly functionality not needed for now''' '''elif frequency == 'weekly': start_time = datetime.datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S') end_time = datetime.datetime.strptime(end_time, '%Y-%m-%d %H:%M:%S') if start_time.date().weekday() != 0: raise ValueError(str(start_time.date())+ " is a " + start_time.date().strftime('%A') + ". start_date must be a Monday.") if end_time.date().weekday() != 6: raise ValueError(str(end_time.date())+ " is a " + end_time.date().strftime('%A') + ". end_date must be a Sunday.") resampling_frequency = 'W' ''' if frequency == 'monthly': resampling_frequency = 'M' if frequency == 'hourly': #Resampling is not necessary return ts else: return ts.resample(resampling_frequency, how='mean', kind='timestamp')