I am trying to write a function that will pull ticker information from Binance and put into a nice chart. I am using pandas and keep getting this error: pandas.core.indexing.IndexingError: Too many indexers
Below is a portion of the code:
def getminutedata(symbol, interval, lookback):
frame = pd.DataFrame(client.get_historical_klines(symbol,interval, lookback + 'min ago CST'))
frame = frame.iloc[:,:,6]
frame.columns = ['Time', 'Open', 'High', 'Low', 'Close', 'Volume']
frame = frame.set_index('Time')
frame.index = pd.to_datetime(frame.index, unit='ms')
frame = frame.astype(float)
return frame
df = getminutedata('ADAUSDT', '1m', '30')
Is there something I am missing?
Because pandas dataframes are 2-dimensional, you can use at most 2 indexers to index a dataframe. You're using 3 (:
, :
, and 6
).
Try changing this line:
frame = frame.iloc[:,:,6]
To this:
frame = frame.iloc[:,6]