BUG: Allow DatetimeIndex for scipy interpolate
Closes #5975

Is there a better way to check for a DatetimeIndex than with an `isinstance()`?

you could try `getattr(v,'asi8',v)`
 should this be posted upstream (scipy) too ?
 I wasn't sure about that. I looked and didn't see any existing issues about interpolation with datetime arrays.

On Jan 16, 2014, at 3:09 PM, "Andy Hayden" <notifications@github.com<mailto:notifications@github.com>> wrote:

should this be posted upstream (scipy) too ?

—
Reply to this email directly or view it on GitHubhttps://github.com/pydata/pandas/pull/5977#issuecomment-32547121.
 this is pretty standard to use only the base types (e.g. float/int64) for most routines (in scipy/numpy), unless they are specific datetime like routines. Pandas just handles these things in a nicer way.
 I believe this introduced an error when compiling the docs:

``` ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-70-c36e7738e696> in <module>()
----> 1 interp_s = ser.reindex(new_index).interpolate(method='pchip')

/home/user1/src/pandas/pandas/core/generic.pyc in interpolate(self, method, axis, limit, inplace, downcast, **kwargs)
   2334                                           inplace=inplace,
   2335                                           downcast=downcast,
-> 2336                                           **kwargs)
   2337 
   2338         if inplace:

/home/user1/src/pandas/pandas/core/internals.pyc in interpolate(self, *args, **kwargs)
   2322 
   2323     def interpolate(self, *args, **kwargs):
-> 2324         return self.apply('interpolate', *args, **kwargs)
   2325 
   2326     def shift(self, *args, **kwargs):

/home/user1/src/pandas/pandas/core/internals.pyc in apply(self, f, *args, **kwargs)
   2293 
   2294             else:
-> 2295                 applied = getattr(blk, f)(*args, **kwargs)
   2296 
   2297             if isinstance(applied, list):

/home/user1/src/pandas/pandas/core/internals.pyc in interpolate(self, method, axis, index, values, inplace, limit, fill_value, coerce, downcast, **kwargs)
    788                                      inplace=inplace,
    789                                      downcast=downcast,
--> 790                                      **kwargs)
    791 
    792         raise ValueError("invalid method '{0}' to interpolate.".format(method))

/home/user1/src/pandas/pandas/core/internals.pyc in _interpolate(self, method, index, values, fill_value, axis, limit, inplace, downcast, **kwargs)
    849 
    850         # interp each column independently
--> 851         interp_values = np.apply_along_axis(func, axis, data)
    852 
    853         blocks = [make_block(interp_values, self.items, self.ref_items,

/usr/lib64/python2.7/site-packages/numpy/lib/shape_base.pyc in apply_along_axis(func1d, axis, arr, *args)
     78     outshape = asarray(arr.shape).take(indlist)
     79     i.put(indlist, ind)
---> 80     res = func1d(arr[tuple(i.tolist())],*args)
     81     #  if res is a number, then we have a smaller output array
     82     if isscalar(res):

/home/user1/src/pandas/pandas/core/internals.pyc in func(x)
    846             return com.interpolate_1d(index, x, method=method, limit=limit,
    847                                       fill_value=fill_value,
--> 848                                       bounds_error=False, **kwargs)
    849 
    850         # interp each column independently

/home/user1/src/pandas/pandas/core/common.pyc in interpolate_1d(xvalues, yvalues, method, limit, fill_value, bounds_error, **kwargs)
   1387         result[firstIndex:][invalid] = _interpolate_scipy_wrapper(
   1388             valid_x, valid_y, new_x, method=method, fill_value=fill_value,
-> 1389             bounds_error=bounds_error, **kwargs)
   1390         if limit:
   1391             result[violate_limit] = np.nan

/home/user1/src/pandas/pandas/core/common.pyc in _interpolate_scipy_wrapper(x, y, new_x, method, fill_value, bounds_error, order, **kwargs)
   1417     if hasattr(x, 'asi8'):
   1418         # GH 5975, scipy.interp1d can't hande datetime64s
-> 1419         x, new_x = x.values.view('i8'), new_x.view('i8')
   1420 
   1421     try:

TypeError: Cannot change data-type for object array.
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-71-b33d2ca06c23> in <module>()
----> 1 interp_s[49:51]


```
 @TomAugspurger ahh...instead of using `x.values.view('i8')`, just astype it, e.g. `x.values.astype('i8')`
I think will fix this
