import pandas as pd from alpha_vantage.timeseries import TimeSeriesfrom alpha_vantage.techindicators import TechIndicators ts = TimeSeries(key=api_key, output_format = 'pandas')ti = TechIndicators(key=api_key, output_format='pandas')data1, meta_data1 = ts.get_intraday(symbol = 'GOOGL' ,interval = '5min', outputsize = 'full')data2, meta_data2 = ti.get_bbands(symbol = 'GOOGL' , interval='5min', time_period=60)data = pd.concat([data1, data2], axis=1, sort=False)data = data.rename(columns={'1. open': 'Open', '2. high': 'High', '3. low': 'Low', '4. close': 'Close'}, inplace = True)data.head()在上面的代碼中,我從 alpha vantage api 導(dǎo)入數(shù)據(jù)。但是出現(xiàn)了上面的錯(cuò)誤。請(qǐng)幫我!
1 回答

神不在的星期二
TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊
當(dāng)您使用 時(shí)inplace=True
,該rename
函數(shù)會(huì)就地執(zhí)行操作,并且不會(huì)返回包含重命名列的數(shù)據(jù)框。相反,它返回None
,然后將其分配給data
- 使其成為 NoneType 對(duì)象。由于data
不再是 df,因此調(diào)用head()
它會(huì)導(dǎo)致您遇到錯(cuò)誤。
添加回答
舉報(bào)
0/150
提交
取消