Skip to content
Snippets Groups Projects
Commit 25c6e3c0 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

ENH: Return empty dataframe in case of empty container

parent 73a52aea
No related branches found
No related tags found
2 merge requests!100WIP: Filling XLSX: Seems to be working.,!99FIX: `to_table` failed on lists
Pipeline #50265 passed with warnings
......@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ###
* `table_converter.to_table` now returns an empty DataFrame instead of raising a
ValueError when called with an empty container.
### Deprecated ###
### Removed ###
......
......@@ -52,8 +52,7 @@ def to_table(container):
"""Create a table from the records in a container."""
if len(container) == 0:
raise ValueError("Container is empty")
# TODO Why not this? return pd.DataFrame()
return pd.DataFrame()
rts = {p.name for p in container[0].parents}
data = []
......
......@@ -43,7 +43,8 @@ class TableTest(unittest.TestCase):
def test_empty(self):
c = db.Container()
self.assertRaises(ValueError, to_table, c)
df = to_table(c)
assert df.shape == (0, 0)
def test_different_props(self):
r1 = db.Record()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment