Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Google API、Python3接收电子表格信息时出错_Python_Python 3.x_Pandas_Dataframe_Google Sheets - Fatal编程技术网

从Google API、Python3接收电子表格信息时出错

从Google API、Python3接收电子表格信息时出错,python,python-3.x,pandas,dataframe,google-sheets,Python,Python 3.x,Pandas,Dataframe,Google Sheets,我在尝试从谷歌电子表格API获取数据时遇到困难。 这是完整的代码源代码:: # -*- coding: utf-8 -*- import gspread import gspread_dataframe as gd from oauth2client.service_account import ServiceAccountCredentials # use creds to create a client to interact with the Google Drive API s

我在尝试从谷歌电子表格API获取数据时遇到困难。 这是完整的代码源代码::

# -*- coding: utf-8 -*-

import gspread
import gspread_dataframe as gd
from oauth2client.service_account import ServiceAccountCredentials




# use creds to create a client to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('C:/Users/yoong/Desktop/Prediction/GoogleSpreadsheetAI-07379c2b7c0d.json', scope)
client = gspread.authorize(creds)

# Find a workbook by name and open the first sheet
# Make sure you use the right name here.
sheet = client.open("Korean Stock Info").sheet1

existing = gd.get_as_dataframe(sheet)
updated = existing.append(sheet)
gd.set_with_dataframe(sheet, updated)

print(sheet.cell(6, 2).value)
我得到一个错误,说

TypeError: cannot concatenate object of type "<class 'gspread.models.Worksheet'>"; only pd.Series, pd.DataFrame, and pd.Panel (deprecated) objs are valid
TypeError:无法连接类型为“”的对象;只有pd.Series、pd.DataFrame和pd.Panel(已弃用)OBJ有效

但是我从变量列表中正确地获取了数据帧。有什么想法吗?

现有的
参数。append
必须是一个数据帧或一个序列,您尝试传递一个gspread工作表对象。从形式上讲是正确的

updated = existing.append(gd.get_as_dataframe(sheet))
但除此之外,您的程序中似乎存在一个逻辑缺陷,因为更新后的
版本将只是原来版本的两倍。也许你打算做一些类似的事情

updated = existing.append(gd.get_as_dataframe(another_sheet))