diff --git a/holoviews/core/data/interface.py b/holoviews/core/data/interface.py index 377a196469..9adc3a5f4e 100644 --- a/holoviews/core/data/interface.py +++ b/holoviews/core/data/interface.py @@ -290,6 +290,8 @@ def range(cls, dataset, dimension): return (np.nanmin(column), np.nanmax(column)) except TypeError: column = [v for v in util.python2sort(column) if v is not None] + if not len(column): + return np.NaN, np.NaN return column[0], column[-1] @classmethod diff --git a/holoviews/core/data/pandas.py b/holoviews/core/data/pandas.py index ddf7105898..1b5e7ea385 100644 --- a/holoviews/core/data/pandas.py +++ b/holoviews/core/data/pandas.py @@ -142,6 +142,8 @@ def range(cls, columns, dimension): else: column = column.sort_values() column = column[~column.isin([None])] + if not len(column): + return np.NaN, np.NaN return column.iloc[0], column.iloc[-1] else: return (column.min(), column.max()) @@ -292,6 +294,16 @@ def dframe(cls, columns, dimensions): return columns.data.copy() + @classmethod + def array(cls, dataset, dimensions): + if not dimensions: + dimensions = dataset.dimensions(label='name') + else: + dimensions = [dataset.get_dimensions(d).name for d in dimensions] + inds = [dataset.data.columns.index(dim.name) for dim in dimensions] + return dataset.data.values[:, inds] + + @classmethod def iloc(cls, dataset, index): rows, cols = index