简体   繁体   中英

Trying to print the first high value from yahoo stock data, getting “At based indexing on an non-integer index can only have non-integer indexers”

I'm trying to write a simple test program to get the high prices of stock data from yahoo. I am getting the data and can display the dataframe with all the information just fine.

But when I try to get the first high price and store it I get the following error:

At based indexing on an non-integer index can only have non-integer indexers

This is the code I'm running:

import pandas_datareader.data as web
import datetime as dt

start=dt.datetime(2018,1,1)
end=dt.datetime(2019,7,1)

df=web.DataReader('BTC-USD', 'yahoo', start, end)
print(df)
h=df.at[1,"High"]   # this line causes the error
print(h)

start = dt.datetime(2018,1,1)v = df.at [start,“ High”]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM