how to remove part of string "test_" in column headers. image the dataframe has many columns, so df.rename(columns={"test_Stock B":"Stock B"}) is not the solution i am looking for!
import pandas as pd
data = {'Stock A':[1, 1, 1, 1],
'test_Stock B':[3, 3, 4, 4],
'Stock C':[4, 4, 3, 2],
'test_Stock D':[2, 2, 2, 3],
}
df = pd.DataFrame(data)
# expect
data = {'Stock A':[1, 1, 1, 1],
'Stock B':[3, 3, 4, 4],
'Stock C':[4, 4, 3, 2],
'Stock D':[2, 2, 2, 3],
}
df_expacte = pd.DataFrame(data)
I expect all column headers only labeled as "Stock x" instead of "test_Stock x". Thank you for the ideas!