Rename Attributes

Learn to rename attributes using pandas and PySpark.

In an organization, data is generated from different sources, systems, and processes before it reaches us, so the column naming might surprise us. We’ll encounter different ways of column naming such camelCaseCamel case is the practice of writing phrases without spaces or punctuation, indicating the separation of words with a single capitalized letter, and the first word starting with either case. Common examples include “iPhone” and “eBay”., snake caseSnake case refers to the style of writing in which each space is replaced by an underscore character, and the first letter of each word written in lowercase. It is a commonly used naming convention in computing, for example for variable and subroutine names, and for filenames. and so on.

Note: We should have a standard that we follow. We’ll use snake case when naming the columns.

Rename columns in pandas

The following code converts the column names of the pandas DataFrame into our desired format:

Get hands-on with 1200+ tech skills courses.