16. Four series objects Tempi, Temp2, Temp3 and Temp4 store the temperatures of week1, week2, week3 and week4 respectively. Create a dataframe from these four series objects where the indexes should be ‘Sunday’, ‘Monday’, … , ‘Saturday’, and columns should be ‘Week1’, ‘Week2’, ‘Week3’ and ‘Week4’.

import pandas as pd

Temp1 = pd.Series([98, 99, 99, 96, 90, 94, 95])
Temp2 = pd.Series([92, 96, 92, 93, 97, 93, 93])
Temp3 = pd.Series([93, 91, 94, 96, 95, 92, 90])
Temp4 = pd.Series([95, 90, 99, 95, 96, 91, 95])

df = pd.DataFrame({‘Week1’:Temp1, ‘Week2’:Temp2, ‘Week3’:Temp3, ‘Week4’:Temp4}) # Adding each Series as a column in our dataframe
df[‘index_col’] = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’] # creating a new column for indexes
df.set_index(‘index_col’, inplace=True) # setting the index_col as index
print(df)

# Output
Week1 Week2 Week3 Week4
index_col
Sunday 98 92 93 95
Monday 99 96 91 90
Tuesday 99 92 94 99
Wednesday 96 93 96 95
Thursday 90 97 95 96
Friday 94 93 92 91
Saturday 95 93 90 95