Skip to content

Commit

Permalink
[DataFrame] Refactor indexers and implement setitem (ray-project#2020)
Browse files Browse the repository at this point in the history
* Reset to_pandas change; update current

* Fix pd_df bug
  • Loading branch information
simon-mo authored and devin-petersohn committed May 15, 2018
1 parent 79b45c6 commit 825c227
Show file tree
Hide file tree
Showing 4 changed files with 528 additions and 86 deletions.
10 changes: 4 additions & 6 deletions python/ray/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5027,9 +5027,8 @@ def loc(self):
We currently support: single label, list array, slice object
We do not support: boolean array, callable
"""
raise NotImplementedError(
"To contribute to Pandas on Ray, please visit "
"github.com/ray-project/ray.")
from .indexing import _Loc_Indexer
return _Loc_Indexer(self)

@property
def is_copy(self):
Expand All @@ -5054,9 +5053,8 @@ def iloc(self):
We currently support: single label, list array, slice object
We do not support: boolean array, callable
"""
raise NotImplementedError(
"To contribute to Pandas on Ray, please visit "
"github.com/ray-project/ray.")
from .indexing import _iLoc_Indexer
return _iLoc_Indexer(self)

def _copartition(self, other, new_index):
"""Colocates the values of other with this for certain operations.
Expand Down
10 changes: 10 additions & 0 deletions python/ray/dataframe/index_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,13 @@ def convert_to_index_sliceable(self, key):
key: slice to convert and check
"""
return convert_to_index_sliceable(self._coord_df, key)

def get_partition(self, partition_id):
"""Return a view of coord_df where partition = partition_id
"""
return self._coord_df[self._coord_df.partition == partition_id]

def sorted_index(self):
return (self._coord_df
.sort_values(['partition', 'index_within_partition'])
.index)
Loading

0 comments on commit 825c227

Please sign in to comment.