diff --git a/holoviews/core/data/grid.py b/holoviews/core/data/grid.py index 9cbce3278f..5f1f30eafe 100644 --- a/holoviews/core/data/grid.py +++ b/holoviews/core/data/grid.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +import datetime as dt from collections import OrderedDict, defaultdict, Iterable try: @@ -188,6 +189,9 @@ def _infer_interval_breaks(cls, coord, axis=0): [ 2.5, 3.5, 4.5]]) """ coord = np.asarray(coord) + if sys.version_info.major == 2 and len(coord) and isinstance(coord[0], (dt.datetime, dt.date)): + # np.diff does not work on datetimes in python 2 + coord = coord.astype('datetime64') deltas = 0.5 * np.diff(coord, axis=axis) first = np.take(coord, [0], axis=axis) - np.take(deltas, [0], axis=axis) last = np.take(coord, [-1], axis=axis) + np.take(deltas, [-1], axis=axis)