#NEWLINE# def get_values_for_date_ranges( zip_date_index_with_vals , vals_for_date_intervals , starts , ends , date_index ) : #NEWLINE# #INDENT# '\n    Returns a Series of values indexed by date based on the intervals defined\n    by the start and end dates.\n\n    Parameters\n    ----------\n    zip_date_index_with_vals : callable\n        A function that takes in a list of dates and a list of values and\n        returns a pd.Series with the values indexed by the dates.\n    vals_for_date_intervals : list\n        A list of values for each date interval in `date_intervals`.\n    starts : DatetimeIndex\n        A DatetimeIndex of start dates.\n    ends : list\n        A DatetimeIndex of end dates.\n    date_index : DatetimeIndex\n        The DatetimeIndex containing all dates for which values were requested.\n\n    Returns\n    -------\n    date_index_with_vals : pd.Series\n        A Series indexed by the given DatetimeIndex and with values assigned\n        to dates based on the given date intervals.\n    ' #NEWLINE# end_indexes = date_index . values . searchsorted ( ends ) #NEWLINE# start_indexes = date_index . values . searchsorted ( starts ) #NEWLINE# num_days = ( ( end_indexes - start_indexes ) + 1 ) #NEWLINE# num_days [ np . where ( ( ( ~ np . in1d ( ends , date_index ) ) & ( num_days != 0 ) ) ) ] -= 1 #NEWLINE# return zip_date_index_with_vals ( date_index , np . repeat ( vals_for_date_intervals , num_days ) )