Pandas DataFrame: add_prefix() function
DataFrame - add_prefix() function
The add_prefix() function is used to prefix labels with string prefix.
For Series, the row labels are prefixed. For DataFrame, the column labels are prefixed.
Syntax:
DataFrame.add_prefix(self, prefix)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
prefix | The string to add before each label. |
str | Required |
Returns: Series or DataFrame
New Series or DataFrame with updated labels.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - nunique() function
Next: DataFrame - add_suffix() function
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join