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
Another option is to rename using a regular expression:
import pandas as pd import re df = pd.DataFrame({'$a':[1,2], '$b':[3,4], '$c':[5,6]}) df = df.rename(columns=lambda x: re.sub('\$','',x)) >>> df a b c 0 1 3 5 1 2 4 6