pydata/pandas — pull request #7452 by sinhrks (2014-06-13 21:58:09+00:00)
Title: ENH/API: offsets funcs now accepts datetime64

Even though ``CustomBusinessDay.apply`` can handle ``np.datetime64``, most of other offsets cannot accept ``datetime64`` and raises ``ApplyTypeError``. The fix allows all offsets ``apply``, ``rollforward`` and ``rollback`` to handle ``np.datetime64`` properly.

```
import pandas as pd
import numpy as np
t = np.datetime64('2011-01-01 09:00Z')

cday = pd.offsets.CustomBusinessDay()
cday.apply(t)
# 2011-01-02 09:00:00

day = pd.offsets.Day()
day.apply(t)
# pandas.tseries.offsets.ApplyTypeError: Unhandled type: datetime64
```

**NOTE:** ``CustomBusinessDay`` had separate logic for ``datetime`` and ``np.datetime64``. Based on the comparison using current master, ``np.datetime64`` logic looks slower. Thus I removed it.

```
import timeit
setup = """
import pandas as pd
import numpy as np

cday = pd.offsets.CustomBusinessDay()

np_dt64 = [np.datetime64('2014-05-{0:02} 09:00Z'.format(i)) for i in range(1, 31)]
timestamps = [pd.Timestamp('2014-05-{0:02} 09:00Z'.format(i)) for i in range(1, 31)]
t = np.datetime64('2014-05-05 09:00Z')
"""

t = timeit.Timer('[cday.apply(d) for d in np_dt64]', setup)
print t.timeit(1000)
# 1.6253619194
t = timeit.Timer('[cday.apply(d) for d in timestamps]', setup)
print t.timeit(1000)
# 0.959406137466
```