Jeevandeep Samanta
Jeevandeep Samanta

Reputation: 11

Rename Column names in DataFrame read from csv and again write to a csv

The code should read the column names from a csv file and I want to append the column names to %%column name. For example: empid, Name, salary so the output should be %%empid Name salary. But the name of the columns will change as different csv will have different column names.

Upvotes: 1

Views: 514

Answers (1)

Stefan
Stefan

Reputation: 42875

This could be accomplished by:

df = read_csv(path)    
df.columns = ['%%{}'.format(c) for c in df.columns]

Upvotes: 2

Related Questions