xorbits.pandas.DataFrame.set_axis#
- DataFrame.set_axis(labels, axis=0, inplace=False)#
Assign desired index to given axis.
Indexes for column or row labels can be changed by assigning a list-like or Index.
- Parameters
labels (list-like, Index) – The values for the new index.
axis ({0 or 'index', 1 or 'columns'}, default 0) – The axis to update. The value 0 identifies the rows. For Series this parameter is unused and defaults to 0.
inplace (bool, default False) –
Whether to return a new DataFrame instance.
Deprecated since version 1.5.0.
copy (bool, default True (Not supported yet)) –
Whether to make a copy of the underlying data.
New in version 1.5.0.
- Returns
renamed – An object of type DataFrame or None if
inplace=True.- Return type
DataFrame or None
See also
DataFrame.rename_axisAlter the name of the index or columns. Examples ——– >>> df = pd.DataFrame({“A”: [1, 2, 3], “B”: [4, 5, 6]}) # doctest: +SKIP Change the row labels. >>> df.set_axis([‘a’, ‘b’, ‘c’], axis=’index’) # doctest: +SKIP A B a 1 4 b 2 5 c 3 6 Change the column labels. >>> df.set_axis([‘I’, ‘II’], axis=’columns’) # doctest: +SKIP I II 0 1 4 1 2 5 2 3 6 Now, update the labels without copying the underlying data. >>> df.set_axis([‘i’, ‘ii’], axis=’columns’, copy=False) # doctest: +SKIP i ii 0 1 4 1 2 5 2 3 6
This docstring was copied from pandas.core.frame.DataFrame.