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)))
评论列表
文章目录