Skip to content

Perspective-Python does not support DataFrames with categorical axis #1158

Closed
@sc1f

Description

Bug Report

Steps to Reproduce:

  1. Create a dataframe with a categorical axis.
  2. Attempt to load into a PerspectiveWidget or Table.

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.

Screen Shot 2020-08-19 at 1 17 40 PM

Environment:

Latest master

Additional Context:

Loading works fine with the column converted to string:

Screen Shot 2020-08-19 at 1 22 22 PM

and converted to dict:

Screen Shot 2020-08-19 at 1 22 40 PM

Looks like a problem in _accessor.py and our Pandas loading code.

Metadata

Assignees

No one assigned

    Labels

    PythonbugConcrete, reproducible bugsgood first issueA relatively simple issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions