---
title: Efficient Column Renaming in eZintegration Using Python Operation
date: 2025-12-30T06:32:09Z
modified: 2026-06-12T10:59:26Z
permalink: "https://ezintegrations.ai/docs/how-to-rename-columns-using-python/"
type: docs
status: publish
excerpt: ""
wpid: 3125
doc_category:
  - Appendix
author: Arun Thakur
---

## Overview

This guide explains how to use the Python Operation in eZintegration to efficiently rename multiple columns in a dataset. While the built-in Rename operation is suitable for renaming individual fields, Python enables dynamic and scalable column renaming when working with large datasets.

By using a simple script, users can automatically apply consistent prefixes or naming conventions across multiple columns in a single operation.

---

## When to Use

Use this approach when bulk column renaming is required within an integration pipeline.

- When renaming multiple columns at once
- When applying consistent prefixes or suffixes
- When processing large datasets
- When handling dynamic or changing schemas
- When improving naming standardization

---

## How It Works

The Python Operation accesses the dataset, iterates through each record, and updates column names by adding a predefined prefix.

- Read the dataset from bizdata\_dataset\_response
- Extract the items array
- Loop through each record
- Prepend a prefix to every column name
- Replace the original dataset with updated values

---

## How to Configure

### Python Operation Setup

Add a Python operation to your integration workflow and insert the following script.

📋Responsedata = []

new_data = pycode_data
prefix = "billTo_"

# Extract items from the dataset response
items = new_data["bizdata_dataset_response"]["items"]
updated_items = []

# Iterate through the items and rename each column by adding the prefix
for item in items:
    updated_item = {}
    for key, value in item.items():
        new_key = f'{prefix}{key}'
        updated_item[new_key] = value
    updated_items.append(updated_item)

# Update the original dataset with the renamed columns
new_data["bizdata_dataset_response"]["items"] = updated_items
pycode_data = new_data


---

## Key Parameters

The script uses the following configurable parameters.



| Parameter | Description |
| --- | --- |
| prefix | Defines the prefix added to each column name (e.g., billTo\_) |
| items | Dataset array located under bizdata\_dataset\_response |

---

## Example Use Case

This approach is useful when applying standardized naming conventions across multiple records.

- Prefixing billing-related fields
- Preparing data for ERP or CRM systems
- Normalizing field names for analytics
- Handling schema changes
- Aligning with target system requirements

---

## Troubleshooting

- **KeyError:** Verify that bizdata\_dataset\_response and items exist.
- **No Columns Renamed:** Confirm the prefix value is set.
- **Empty Output:** Check that items contains records.
- **Script Failure:** Validate Python syntax.
- **Unexpected Fields:** Review original dataset structure.

---

## Frequently Asked Questions

 ### 1. Can I use this script to add a suffix instead of a prefix?

 Yes. Modify the new\_key assignment to append the suffix after the key name.

 

 

  ### 2. Does this script overwrite original column names?

 Yes. The original keys are replaced with prefixed versions in the output dataset.

 

 

  ### 3. Can I rename only selected columns?

 Yes. Add conditional logic inside the loop to filter specific keys.

 

 

  ### 4. Is this approach scalable?

 Yes. It supports large datasets and dynamic schemas.

 

 

  ### 5. Do I still need the Rename operation?

 The Rename operation is suitable for small, individual changes. Python is recommended for bulk transformations.

 

 

 ---

## Notes

- - Always test scripts in preview mode.
    - Back up original datasets before transformation.
    - Use consistent naming conventions.

## Topics

**Docs Categories:** [Appendix](https://ezintegrations.ai/wp-content/uploads/wp-mfa-exports/taxonomy/doc_category/appendix.md)