Why do we set the index to a datetime object?

reliance_minute_data =  yf.download(tickers='RELIANCE.NS',period="5d",interval='1m',auto_adjust=True)
reliance_minute_data.tail(1)


------------------------------------------------

reliance_minute_data =  yf.download(tickers='RELIANCE.NS',period="5d",interval='1m',auto_adjust=True)
reliance_minute_data.index = pd.to_datetime(reliance_minute_data.index)
reliance_minute_data.tail(1)

 

  • The above two sections of code gives the same output , then why do we need to explicitly convert the index of the download function to "datetime" and then again setting it as an index of our data.
  • In the course example the company used was : "AAPL" and the dataset name = "apple_minute_data"

Hi Rajat



Yes, you are indeed right! yfinance automatically handles the operation being executed by "pd.to_datetime()". Thanks for pointing it out. We will make the change in the notebook. 



Thanks and Regards,

Rishabh