Skip to content

Commit

Permalink
Handle None as DataFrame.value (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Jun 4, 2020
1 parent d3514b3 commit 9625fe1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions panel/tests/widgets/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,12 @@ def test_hierarchical_index(document, comm):
assert isinstance(agg1, MinAggregator)
assert agg2.field_ == 'Float'
assert isinstance(agg2, MinAggregator)


def test_none_table(document, comm):
table = DataFrame(value=None)
assert table.indexes == []

model = table.get_root(document, comm)

assert model.source.data == {}
4 changes: 3 additions & 1 deletion panel/widgets/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def _validate(self, event):
@property
def indexes(self):
import pandas as pd
if isinstance(self.value.index, pd.MultiIndex):
if self.value is None:
return []
elif isinstance(self.value.index, pd.MultiIndex):
return list(self.value.index.names)
return [self.value.index.name or 'index']

Expand Down

0 comments on commit 9625fe1

Please sign in to comment.