Skip to content

Commit

Permalink
Handled empty values
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 15, 2018
1 parent 3a8b71a commit ff26b55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions holoviews/core/data/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions holoviews/core/data/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff26b55

Please sign in to comment.