I am currently trying to change the following column names:
Unnamed: 1 | Unnamed: 2 <----- Column names Alfa Beta <----- Data Into:
2016 | 2017 Alfa Beta I have used:
df.rename(columns=lambda x: re.sub(r"Unnamed\:\s\d+"," ",x)) To replace the column names with a blank space, but I want to create a loop so automatically can be replaced into 2016 and 2017
[Additionally] I made this to create the list of values
for i in range(len(df.columns[:])): i+=2016 str(i) Result gives:
2016 2017 Is there any method in which I can substitute those values into the list comprehension?