I have a DataFrame using pandas and column labels that I need to edit to replace the original column labels.
I\'d like to change the column names in a DataFrame
Assuming you can use regular expression. This solution removes the need of manual encoding using regex
import pandas as pd import re srch=re.compile(r"\w+") data=pd.read_csv("CSV_FILE.csv") cols=data.columns new_cols=list(map(lambda v:v.group(),(list(map(srch.search,cols))))) data.columns=new_cols