コード例 #1
0
ファイル: multiindex.py プロジェクト: williamBlazing/cudf
 def copy(self, deep=True):
     mi = MultiIndex(source_data=self._source_data.copy(deep))
     if self._levels is not None:
         mi._levels = [s.copy(deep) for s in self._levels]
     if self._codes is not None:
         mi._codes = self._codes.copy(deep)
     if self.names is not None:
         mi.names = self.names.copy()
     return mi
コード例 #2
0
 def copy(self, deep=True):
     if hasattr(self, '_source_data'):
         mi = MultiIndex(source_data=self._source_data)
         if self._levels is not None:
             mi._levels = self._levels.copy()
         if self._codes is not None:
             mi._codes = self._codes.copy(deep)
     else:
         mi = MultiIndex(self.levels.copy(), self.codes.copy(deep))
     if self.names is not None:
         mi.names = self.names.copy()
     return mi
コード例 #3
0
ファイル: multiindex.py プロジェクト: woodworker2017/cudf
    def take(self, indices):
        from collections.abc import Sequence
        from cudf import Series
        from numbers import Integral

        if isinstance(indices, (Integral, Sequence)):
            indices = np.array(indices)
        elif isinstance(indices, Series):
            indices = indices.to_gpu_array()
        elif isinstance(indices, slice):
            start, stop, step = indices.indices(len(self))
            indices = cudautils.arange(start, stop, step)
        result = MultiIndex(source_data=self._source_data.take(indices))
        if self._codes is not None:
            result._codes = self._codes.take(indices)
        if self._levels is not None:
            result._levels = self._levels
        result.names = self.names
        return result
コード例 #4
0
ファイル: multiindex.py プロジェクト: williamBlazing/cudf
    def take(self, indices):
        from collections.abc import Sequence
        from cudf import Series
        from numbers import Integral

        if isinstance(indices, (Integral, Sequence)):
            indices = np.array(indices)
        elif isinstance(indices, Series):
            if indices.null_count != 0:
                raise ValueError("Column must have no nulls.")
            indices = indices.data.mem
        elif isinstance(indices, slice):
            start, stop, step = indices.indices(len(self))
            indices = cudautils.arange(start, stop, step)
        result = MultiIndex(source_data=self._source_data.take(indices))
        if self._codes is not None:
            result._codes = self._codes.take(indices)
        if self._levels is not None:
            result._levels = self._levels
        result.names = self.names
        return result