Login using Social Account
     Continue with GoogleLogin using your credentials
Since 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.to_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 >>()
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...