Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle None as DataFrame.value #1384

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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