def interp_time_series(series, time=None, other=None): """ Interpolate time series values on index of other :param series: pandas Series :param time: pandas DatetimeIndex or equivalent :param other: pandas Series :return: """ series_julian_time = Series(series.index.to_julian_date(), series.index) if other is None: try: time = DatetimeIndex(time) other_julian_time = Series(time.to_julian_date(), time) except ValueError: raise TypeError( "'time' must either be or convertible into a DatetimeIndex") except AttributeError: raise ValueError("Either 'other' or 'time' must be passed") else: other_julian_time = Series(other.index.to_julian_date(), other.index) time = other.index # Interpolate values value_interp = interp(other_julian_time.values, series_julian_time.values, series.values) return Series(data=value_interp, index=time)