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

Slicing single row of XDataFrame does not work #19

Open
mloning opened this issue Jan 17, 2019 · 0 comments
Open

Slicing single row of XDataFrame does not work #19

mloning opened this issue Jan 17, 2019 · 0 comments

Comments

@mloning
Copy link
Collaborator

mloning commented Jan 17, 2019

Slicing of single row in XDataFrame does not work, probably because it tries to return a series which does not work as types are heterogeneous, so instead one may want to return a XDataFrame with a single row.

import pandas as pd
from xpandas.data_container import XDataFrame

iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
iris.iloc[0] # works

irisx = XDataFrame(iris) 
irisx.iloc[0] # breaks

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-32-b46ce52f9af0> in <module>
----> 1 irisx.iloc[0]

~/.conda/envs/sktime/lib/python3.7/site-packages/pandas/core/indexing.py in __getitem__(self, key)
   1476 
   1477             maybe_callable = com._apply_if_callable(key, self.obj)
-> 1478             return self._getitem_axis(maybe_callable, axis=axis)
   1479 
   1480     def _is_scalar_access(self, key):

~/.conda/envs/sktime/lib/python3.7/site-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis)
   2102             self._validate_integer(key, axis)
   2103 
-> 2104             return self._get_loc(key, axis=axis)
   2105 
   2106     def _convert_to_indexer(self, obj, axis=None, is_setter=False):

~/.conda/envs/sktime/lib/python3.7/site-packages/pandas/core/indexing.py in _get_loc(self, key, axis)
    143         if axis is None:
    144             axis = self.axis
--> 145         return self.obj._ixs(key, axis=axis)
    146 
    147     def _slice(self, obj, axis=None, kind=None):

~/.conda/envs/sktime/lib/python3.7/site-packages/pandas/core/frame.py in _ixs(self, i, axis)
   2624                                                       index=self.columns,
   2625                                                       name=self.index[i],
-> 2626                                                       dtype=new_values.dtype)
   2627                 result._set_is_copy(self, copy=copy)
   2628                 return result

~/.conda/envs/sktime/lib/python3.7/site-packages/xpandas/data_container/data_container.py in __init__(self, *args, **kwargs)
     71         check_result, data_type = _check_all_elements_have_the_same_property(data, type)
     72         if not check_result:
---> 73             raise ValueError('Not all elements the same type')
     74 
     75         if data_type is not None:

ValueError: Not all elements the same type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant