mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Add slice functionality (#1832)
This commit is contained in:
parent
f505f0642f
commit
3c817ad908
1 changed files with 10 additions and 3 deletions
|
@ -2945,9 +2945,7 @@ class DataFrame(object):
|
||||||
# see if we can slice the rows
|
# see if we can slice the rows
|
||||||
indexer = self._row_metadata.convert_to_index_sliceable(key)
|
indexer = self._row_metadata.convert_to_index_sliceable(key)
|
||||||
if indexer is not None:
|
if indexer is not None:
|
||||||
raise NotImplementedError("To contribute to Pandas on Ray, please"
|
return self._getitem_slice(indexer)
|
||||||
"visit github.com/ray-project/ray.")
|
|
||||||
# return self._getitem_slice(indexer)
|
|
||||||
|
|
||||||
if isinstance(key, (pd.Series, np.ndarray, pd.Index, list)):
|
if isinstance(key, (pd.Series, np.ndarray, pd.Index, list)):
|
||||||
return self._getitem_array(key)
|
return self._getitem_array(key)
|
||||||
|
@ -3015,6 +3013,15 @@ class DataFrame(object):
|
||||||
lambda df: df.__getitem__(index),
|
lambda df: df.__getitem__(index),
|
||||||
self._col_partitions[part])
|
self._col_partitions[part])
|
||||||
|
|
||||||
|
def _getitem_slice(self, key):
|
||||||
|
new_cols = _map_partitions(lambda df: df[key],
|
||||||
|
self._col_partitions)
|
||||||
|
|
||||||
|
index = self.index[key]
|
||||||
|
return DataFrame(col_partitions=new_cols,
|
||||||
|
index=index,
|
||||||
|
columns=self.columns)
|
||||||
|
|
||||||
def __getattr__(self, key):
|
def __getattr__(self, key):
|
||||||
"""After regular attribute access, looks up the name in the columns
|
"""After regular attribute access, looks up the name in the columns
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue