cudf.DataFrame.reindex#
- DataFrame.reindex(labels=None, axis=None, index=None, columns=None, copy=True)#
Return a new DataFrame whose axes conform to a new index
DataFrame.reindex
supports two calling conventions:(index=index_labels, columns=column_names)
(labels, axis={0 or 'index', 1 or 'columns'})
- Parameters
- labelsIndex, Series-convertible, optional, default None
- axis{0 or ‘index’, 1 or ‘columns’}, optional, default 0
- indexIndex, Series-convertible, optional, default None
Shorthand for
df.reindex(labels=index_labels, axis=0)
- columnsarray-like, optional, default None
Shorthand for
df.reindex(labels=column_names, axis=1)
- copyboolean, optional, default True
- Returns
- A DataFrame whose axes conform to the new index(es)
Examples
>>> import cudf >>> df = cudf.DataFrame() >>> df['key'] = [0, 1, 2, 3, 4] >>> df['val'] = [float(i + 10) for i in range(5)] >>> df_new = df.reindex(index=[0, 3, 4, 5], ... columns=['key', 'val', 'sum']) >>> df key val 0 0 10.0 1 1 11.0 2 2 12.0 3 3 13.0 4 4 14.0 >>> df_new key val sum 0 0 10.0 <NA> 3 3 13.0 <NA> 4 4 14.0 <NA> 5 <NA> <NA> <NA>