Pandas DataFrame: set_axis() function
DataFrame - set_axis() function
The set_axis() function is used to assign desired index to given axis.
Indexes for column or row labels can be changed by assigning a list-like or Index.
Syntax:
DataFrame.set_axis(self, labels, axis=0, inplace=None)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
labels | The values for the new index. | list-like, Index | Required |
axis | The axis to update. The value 0 identifies the rows, and 1 identifies the columns. | {0 or ‘index’, 1 or ‘columns’} Default Value: 0 |
Required |
inplace | Whether to return a new %(klass)s instance. | bool Default Value: None |
Required |
Returns: renamed - %(klass)s or None
An object of same type as caller if inplace=False, None otherwise.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - sample() function
Next: DataFrame - set_index() function
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework