IconResources
Conduct analysis

Rename headers

Change the names of your table's columns to make them easier to read or work with.

Example Data

Follow along with right out of the box example data. Copy following data in the information request of the agent you are working in.



When working with data, renaming column headers can make your table easier to understand, share, or prepare for models. For example, you might want to shorten "Seller Country" to "From" or use lowercase headers for consistency. In this section, you'll learn how to rename columns in your table.

Rename a single column

Excel

In Excel, you double-click the column name and type a new one.

t0 Prompt

Rename the column "Seller Country" to "From"

Change the header "Amount" to "USD Amount"

Code

The python code looks as follows:

transactions.rename(columns={"Seller Country": "From"}, inplace=True)
transactions
FunctionDescription
rename(columns=\{...\})Changes one or more column names
rename(..., inplace=True)Applies the change directly to the table

Replace all headers at once

Excel

In Excel, you can paste a new row of headers to overwrite the old ones.

t0 Prompt

Replace all column names with X, Y, Z

Code

The python code looks as follows:

transactions.columns = [
    "Date", "Seller", "From", "Buyer", "To", "Type", "Currency", "USD Amount"
]
transactions
MethodDescription
rename(columns={...})Change some headers by name
transactions.columns = [...]Replace all headers in the table

On this page