I have the following code:
import pandas as pd
import yfinance as yf
import datetime
from dateutil.relativedelta import relativedelta
import pandas as pd, mplfinance as mpf, matplotlib.pyplot as plt
import numpy as np
db = yf.download(tickers='goog', start=datetime.datetime.now()-relativedelta(days=7), end= datetime.datetime.now(), interval="5m")
db = db.dropna()
If i wanted to get the float value i would just do this "
db.index.get_loc(pd.Timestamp('2022-02-16 12:05:00'))
and it would produce 34
So :
b =db[33:34]
But if i do this:
db.index.get_loc(pd.Timestamp(b.index.strftime('%Y-%m-%d %I:%M:%S')))
I get:
TypeError: Cannot convert input [Index(['2022-02-22 09:15:00'], dtype='object', name='Datetime')] of type <class 'pandas.core.indexes.base.Index'> to Timestamp
Could you please advise how can i get the index from datetime?