I'm trying to find a way to replace characters in multiple column names. I want to change "hld" to "pct" in the name from my 2th and 6th columns. I tried the following code:
df_hld.columns.values[2:7] = df_hld.columns[2:7].str.replace("hld", "pct")
It works in terms of changing names, but later on when I tried to merge the data frame with another one. All the values in those columns returned NaN. I went back to check the dtypes, and they are indeed float64. I really don't know what went wrong here.
Please help!