Perspective-Python does not support DataFrames with categorical axis #1158
Closed
Description
Bug Report
Steps to Reproduce:
- Create a dataframe with a categorical axis.
- Attempt to load into a
PerspectiveWidget
orTable
.
Expected Result:
A valid widget or Table.
Actual Result:
---------------------------------------------------------------------------
PerspectiveError Traceback (most recent call last)
<ipython-input-2-acefd98973df> in <module>
3 "b": [1, 2, 3, 4, 5]
4 })
----> 5 perspective.PerspectiveWidget(df)
~/work/perspective/python/perspective/perspective/widget/widget.py in __init__(self, table_or_data, index, limit, client, **kwargs)
263 load_kwargs.update({"limit": limit})
264
--> 265 self.load(table_or_data, **load_kwargs)
266
267 def load(self, data, **options):
~/work/perspective/python/perspective/perspective/widget/widget.py in load(self, data, **options)
277 self._data = d
278 else:
--> 279 super(PerspectiveWidget, self).load(data, **options)
280
281 # proactively notify front-end of new data
~/work/perspective/python/perspective/perspective/viewer/viewer.py in load(self, table_or_data, **options)
159 table = table_or_data
160 else:
--> 161 table = Table(table_or_data, **options)
162
163 self.manager.host_table(name, table)
~/work/perspective/python/perspective/perspective/table/table.py in __init__(self, data, limit, index)
47 _accessor = data
48 else:
---> 49 _accessor = _PerspectiveAccessor(data)
50
51 self._date_validator = _PerspectiveDateValidator()
~/work/perspective/python/perspective/perspective/table/_accessor.py in __init__(self, data_or_schema)
111
112 if not isinstance(array, numpy.ndarray):
--> 113 raise PerspectiveError("Mixed datasets of numpy.ndarray and lists are not supported.")
114
115 dtype = array.dtype
PerspectiveError: Mixed datasets of numpy.ndarray and lists are not supported.
Environment:
Latest master
Additional Context:
Loading works fine with the column converted to string:
and converted to dict:
Looks like a problem in _accessor.py
and our Pandas loading code.