I'm collecting intraday 1-minute stock data from iexcloud using the API. I load the data into a pandas dataframe and then I am trying to grab a specific row of data for a specific day and minute during the day. I originally tried inputting in the original start variable (which is a datetime object) and that didn't work so I converted the date to pandas format using to_datetime() and tried printing it using print(df[start_p]) but this returns the same error as well. I tried searching older questions but to no avail since I feel the problem here likely stems from this additional "minute" component at the end. Below is the code and the picture shows the dataframe in question. If you look at the input and the corresponding dataframe picture you can see they're the exact same characters and I tried with both timestamp objects and string objects as the key but neither worked. How do I input the appropriate index into here?
import pandas as pd
import datetime #so don't have to do datetime.date())
from iexfinance.stocks import get_historical_data,get_historical_intraday
import matplotlib.pyplot as plt
api='xxx' #https://iexcloud.io/
start = datetime.datetime(2020, 11, 24)
end = datetime.datetime(2020, 12, 20)
df =get_historical_intraday("MSFT",start,output_format='pandas',token=api )
base='df'
for i in range(2):
start += datetime.timedelta(days=1,hours=9,minutes=30)
start_p=pd.to_datetime(start)
#print(start_p)
#df=get_historical_intraday("MSFT",start,output_format='pandas',token=api)
att={'label':[215.23],'low':[213.92]} #for SO -- reproducing part of dataset
df=pd.DataFrame(att,index=[start_p])
print(df["2020-11-25 09:30:00"]) #KeyError: '2020-11-25 09:30:00'
print('here')
print(df[start_p]) #KeyError: Timestamp('2020-11-25 09:30:00')