def interpolate_1d(xvalues, yvalues, method='<STR_LIT>', limit=None,<EOL>limit_direction='<STR_LIT>', limit_area=None, fill_value=None,<EOL>bounds_error=False, order=None, **kwargs):
<EOL>invalid = isna(yvalues)<EOL>valid = ~invalid<EOL>if not valid.any():<EOL><INDENT>result = np.empty_like(np.asarray(xvalues), dtype=np.float64)<EOL>result.fill(np.nan)<EOL>return result<EOL><DEDENT>if valid.all():<EOL><INDENT>return yvalues<EOL><DEDENT>if method == '<STR_LIT:time>':<EOL><INDENT>if not getattr(xvalues, '<STR_LIT>', None):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>method = '<STR_LIT>'<EOL><DEDENT>valid_limit_directions = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>limit_direction = limit_direction.lower()<EOL>if limit_direction not in valid_limit_directions:<EOL><INDENT>msg = ('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>raise ValueError(msg.format(valid=valid_limit_directions,<EOL>invalid=limit_direction))<EOL><DEDENT>if limit_area is not None:<EOL><INDENT>valid_limit_areas = ['<STR_LIT>', '<STR_LIT>']<EOL>limit_area = limit_area.lower()<EOL>if limit_area not in valid_limit_areas:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(valid_limit_areas, limit_area))<EOL><DEDENT><DEDENT>if limit is None:<EOL><INDENT>pass<EOL><DEDENT>elif not is_integer(limit):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif limit < <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>from pandas import Series<EOL>ys = Series(yvalues)<EOL>all_nans = set(np.flatnonzero(invalid))<EOL>start_nans = set(range(ys.first_valid_index()))<EOL>end_nans = set(range(<NUM_LIT:1> + ys.last_valid_index(), len(valid)))<EOL>mid_nans = all_nans - start_nans - end_nans<EOL>if limit_direction == '<STR_LIT>':<EOL><INDENT>preserve_nans = start_nans | set(_interp_limit(invalid, limit, <NUM_LIT:0>))<EOL><DEDENT>elif limit_direction == '<STR_LIT>':<EOL><INDENT>preserve_nans = end_nans | set(_interp_limit(invalid, <NUM_LIT:0>, limit))<EOL><DEDENT>else:<EOL><INDENT>preserve_nans = set(_interp_limit(invalid, limit, limit))<EOL><DEDENT>if limit_area == '<STR_LIT>':<EOL><INDENT>preserve_nans |= start_nans | end_nans<EOL><DEDENT>elif limit_area == '<STR_LIT>':<EOL><INDENT>preserve_nans |= mid_nans<EOL><DEDENT>preserve_nans = sorted(preserve_nans)<EOL>xvalues = getattr(xvalues, '<STR_LIT>', xvalues)<EOL>yvalues = getattr(yvalues, '<STR_LIT>', yvalues)<EOL>result = yvalues.copy()<EOL>if method in ['<STR_LIT>', '<STR_LIT:time>', '<STR_LIT:index>', '<STR_LIT>']:<EOL><INDENT>if method in ('<STR_LIT>', '<STR_LIT:index>'):<EOL><INDENT>inds = np.asarray(xvalues)<EOL>if needs_i8_conversion(inds.dtype.type):<EOL><INDENT>inds = inds.view(np.int64)<EOL><DEDENT>if inds.dtype == np.object_:<EOL><INDENT>inds = lib.maybe_convert_objects(inds)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inds = xvalues<EOL><DEDENT>result[invalid] = np.interp(inds[invalid], inds[valid], yvalues[valid])<EOL>result[preserve_nans] = np.nan<EOL>return result<EOL><DEDENT>sp_methods = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if method in sp_methods:<EOL><INDENT>inds = np.asarray(xvalues)<EOL>if issubclass(inds.dtype.type, np.datetime64):<EOL><INDENT>inds = inds.view(np.int64)<EOL><DEDENT>result[invalid] = _interpolate_scipy_wrapper(inds[valid],<EOL>yvalues[valid],<EOL>inds[invalid],<EOL>method=method,<EOL>fill_value=fill_value,<EOL>bounds_error=bounds_error,<EOL>order=order, **kwargs)<EOL>result[preserve_nans] = np.nan<EOL>return result<EOL><DEDENT>
Logic for the 1-d interpolation.  The result should be 1-d, inputs
xvalues and yvalues will each be 1-d arrays of the same length.

Bounds_error is currently hardcoded to False since non-scipy ones don't
take it as an argument.