Q. Four Series objects Temp1, 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'.


Answer =




import pandas as pd
import numpy as np


df = pd.DataFrame( { "Week1" : [ 17, 18, 19, 20, 20, 79, 5 ], "Week2" : [ 17, 18, 19, 20, 20, 79, 5 ], "Week3" : [ 17, 18, 19, 20, 20, 79, 5 ], \
                   "Week4" : [ 17, 18, 19, 20, 20, 79, 5 ] }, index = [ "Sunday", "Monday", "Tuesday", \
                                           "Wednesday", "Thursday", "Friday", "Saturday" ] )

print(df)



1 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. But no series object is being created here, this is just directly entering data into a DataFrame

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post