Apologies if something similar has been asked before, I searched around but couldn't figure out a solution.
I have a dataframe like such:
df = pd.DataFrame({'A':list('abcdef'),
'B':[4,5,4,5,5,4],
'C':[7,8,9,4,2,3],
'D':[1,3,5,7,1,0],
'E':list('aaabbb')})
I want to rename columns of this dataframe, say, indices [:,1:2] which are B and C in this case, into something with an iterating pattern.
Such as new column names:
A Q1 Q2 D E
There is a prefix and the 1, 2, etc can auto-increment based on the range. An added bonus would be if I could also control the string portion, such that I could get: (given I provide a list with possible entries like =
names = ['Dog','Cat']
A QDog1 QCat2 D E
Any help is appreciated, thanks!