Y2010 Y2011 Y2012 Y2013 test
0 86574 77806 93476 99626 2
1 60954 67873 65135 64418 4
2 156 575 280 330 6
3 1435 1360 1406 1956 7
4 3818 7700 6900 5500 8
Is there a way to rename the columns of this dataframe from Y2010... to 2010.. i.e. removing the initial 'Y'. I want to use regular expressions since I have quite a few such columns. I tried this:
df.rename(df.filter(regex='^Y\d{4}').columns.values, range(2010, 2013 + 1, 1))
--EDIT: The dataframe doees include columns which do not start with a 'Y'