Enrollments Open for Advanced Certification Courses on Data Science, ML & AI by E&ICT Academy IIT Roorkee
Apply NowSince we are dealing with time-series data, it makes sense to see the date column as the index of our data frame.
We shall do this by using the set_index
method on the df_yahoo
data frame.
But before that, let us first convert the "date" column into DateTime type using the pd.to_datetime()
method of pandas.
Note:
pd.to_datetime()
is used to covert the type of column to datetime type.
set_index()
method is used to set the data frame index using existing columns.
Convert the "date" column of the df_yahoo
data frame into datetime type using pd.datetime()
.
df_yahoo['date']= pd.<< your code comes here >>(df_yahoo['date'])
View the type of "date" column of df_yahoo
data frame using dtype
.
print(df_yahoo.date.dtype)
Observe the type of the column was previously "object", whereas it is of type "datetime64[ns]".
Now, set the "date" column as the index of df_yahoo
data frame using the set_index()
method.
df_yahoo = df_yahoo.<< your code comes here >>("date")
View the top 5 rows of df_yahoo
data frame using head()
method.
df_yahoo.<< your code comes here >>()
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...