簡體   English   中英

從 Github 存儲庫將 Excel 文件導入 pandas

[英]Import Excel file to pandas from Github repository

我努力使用以下源代碼將我的私有 Github 存儲庫中的 Excel 文件導出到 Pandas 數據框:

username= 'xxx'
token = 'yyyy'
github_session = requests.Session()
github_session.auth = (username, token)

url = 'correct path to raw file'
export = requests.get(url).content

df = pd.read_excel(io.StringIO(export.decode('utf-8')))

運行上述塊的最后一行時遇到錯誤:

TypeError: unsupported operand type(s) for <<: 'str' and 'int'

來自 Github 存儲庫的 Excel 原始數據文件結合了數字和字符串記錄。

Excel 是二進制文件格式。 改用io.BytesIO(export)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM