core.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:dask_gdf 作者: gpuopenanalytics 项目源码 文件源码
def set_index(self, index, drop=True, sorted=False):
        """Set new index.

        Parameters
        ----------
        index : str or Series
            If a ``str`` is provided, it is used as the name of the
            column to be made into the index.
            If a ``Series`` is provided, it is used as the new index
        drop : bool
            Whether the first original index column is dropped.
        sorted : bool
            Whether the new index column is already sorted.
        """
        if not drop:
            raise NotImplementedError('drop=False not supported yet')

        if isinstance(index, str):
            return self._set_index_raw(index, drop=drop, sorted=sorted)
        elif isinstance(index, Series):
            indexname = '__dask_gdf.index'
            df = self.assign(**{indexname: index})
            return df._set_index_raw(indexname, drop=drop, sorted=sorted)
        else:
            raise TypeError('cannot set_index from {}'.format(type(index)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号