mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
[DataFrame] Allows DataFrame constructor to take in another DataFrame (#2072)
* allow constructor to take in other DataFrame * rename _data to _frame_data
This commit is contained in:
parent
78bb887dd4
commit
7549209aea
1 changed files with 25 additions and 0 deletions
|
@ -78,6 +78,10 @@ class DataFrame(object):
|
|||
col_metadata (_IndexMetadata):
|
||||
Metadata for the new dataframe's columns
|
||||
"""
|
||||
if isinstance(data, DataFrame):
|
||||
self._frame_data = data._frame_data
|
||||
return
|
||||
|
||||
self._dtypes_cache = dtypes_cache
|
||||
|
||||
# Check type of data and use appropriate constructor
|
||||
|
@ -167,6 +171,27 @@ class DataFrame(object):
|
|||
if self._dtypes_cache is None:
|
||||
self._correct_dtypes()
|
||||
|
||||
def _get_frame_data(self):
|
||||
data = {}
|
||||
data['blocks'] = self._block_partitions
|
||||
data['col_metadata'] = self._col_metadata
|
||||
data['row_metadata'] = self._row_metadata
|
||||
data['columns'] = self.columns
|
||||
data['index'] = self.index
|
||||
data['dtypes'] = self._dtypes_cache
|
||||
|
||||
return data
|
||||
|
||||
def _set_frame_data(self, data):
|
||||
self._block_partitions = data['blocks']
|
||||
self._col_metadata = data['col_metadata']
|
||||
self._row_metadata = data['row_metadata']
|
||||
self.columns = data['columns']
|
||||
self.index = data['index']
|
||||
self._dtypes_cache = data['dtypes']
|
||||
|
||||
_frame_data = property(_get_frame_data, _set_frame_data)
|
||||
|
||||
def _get_row_partitions(self):
|
||||
return [_blocks_to_row.remote(*part)
|
||||
for part in self._block_partitions]
|
||||
|
|
Loading…
Add table
Reference in a new issue