import pandas as pd import numpy as np df = pd.DataFrame( { 'A': ['d','d','d','f','f','f','g','g','g','h','h','h'], 'B': [5,5,6,7,5,6,6,7,7,6,7,7], 'C': [1,1,1,1,1,1,1,1,1,1,1,1], 'S': [2012,2013,2014,2015,2016,2012,2013,2014,2015,2016,2012,2013] } ); df I'd like to create a new dataframe, where column A is grouped and the sums of columns B and C are shown in new columns 2012, 2013, 2014, 2015 and 2016.