One can initialize a misc table with None as index:
>>> import audformat
>>> table = audformat.MiscTable(None)
But this let's some of its method fail:
>>> table.copy()
...
ValueError: Got index with levels [None], but names must be non-empty and unique.
>>> table.extend_index(pd.Index([0, 1, 2], name="idx"))
...
ValueError: Got index with levels [None], but names must be non-empty and unique.
>>> table.extend_index(pd.Index([0, 1, 2], name="idx"), inplace=True)
ValueError: Cannot extend table if input index and table index are not alike.
Expected index:
idx int64
but yours is:
None int64
You can extend the table with:
>>> table.extend_index(pd.Index([0, 1, 2]), inplace=True)
>>> table.index
Index([0, 1, 2], dtype='Int64')
But now you have created a table without a name for the index and empty levels:
If you would have tried this when creating the table, it would have failed with
>>> table = audformat.MiscTable(pd.Index([0, 1, 2]))
...
ValueError: Got index with levels [None], but names must be non-empty and unique.
One can initialize a misc table with
Noneas index:But this let's some of its method fail:
You can extend the table with:
But now you have created a table without a name for the index and empty
levels:If you would have tried this when creating the table, it would have failed with