df = pd.DataFrame({
'ID': [1,1,2,2,3,3,3,3],
'Page': [ 'A', 'B','C','C', 'A', 'B','C','B'],
'Time_on_page' : [60,80,120,30,10,50,60,30]
})
# Create Dummies
adf = pd.get_dummies(df, columns=['Page'], drop_first=False).groupby(['ID']).max().reset_index()
# Calculate ID, Page wise Time sums
bdf = df.groupby(['ID','Page'])['Time_on_page'].sum().unstack(['Page']).fillna(0).reset_index()
# Merge both
result = adf.merge(bdf, on=['ID']).drop('Time_on_page', axis=1)
print (result)
ID Page_A Page_B Page_C A B C
1 1 1 0 60.0 80.0 0.0
2 0 0 1 0.0 0.0 150.0
3 1 1 1 10.0 80.0 60.0