code: def interpolate_2d(
      values,
      method="pad",
      axis=0,
      limit=None,
      fill_value=None,
      dtype=None,
  ):
      """perform an actual interpolation of values, values will be make 2-d if
      needed fills inplace, returns the result
      """
  
      transf = (lambda x: x) if axis == 0 else (lambda x: x.T)
  
      # reshape a 1 dim if needed
      ndim = values.ndim
      if values.ndim == 1:
          if axis != 0:  # pragma: no cover
              raise AssertionError(
                  "cannot interpolate on a ndim == 1 with " "axis != 0"
              )
          values = values.reshape(tuple((1,) + values.shape))
  
      if fill_value is None:
          mask = None
      else:  # todo create faster fill func without masking
          mask = mask_missing(transf(values), fill_value)
  
      method = clean_fill_method(method)
      if method == "pad":
          values = transf(
              pad_2d(
                  transf(values), limit=limit, mask=mask, dtype=dtype
              )
          )
      else:
          values = transf(
              backfill_2d(
                  transf(values), limit=limit, mask=mask, dtype=dtype
              )
          )
  
      # reshape back
      if ndim == 1:
          values = values[0]
  
      return values
  
imports: from distutils.version import LooseVersion
  import operator
  import numpy
  from pandas._libs import algos, lib
  from pandas.compat import range, string_types
  from pandas.core.dtypes.cast import infer_dtype_from_array
  from pandas.core.dtypes.common import ensure_float64, is_datetime64_dtype, is_datetime64tz_dtype, is_float_dtype, is_integer, is_integer_dtype, is_numeric_v_string_like, is_scalar, is_timedelta64_dtype, needs_i8_conversion
  from pandas.core.dtypes.missing import isna
label_desc: Use image node_id 8 for calling a global function with example usage: interpolate_2d(values, method, axis, limit, fill_value, dtype) and returns: values