小编sth*_*ium的帖子

无法在 Pandas 中读取 Excel 文件

我正在使用从包含笔记本和 Excel 文件的同一目录启动的 Juypter。我使用以下命令:

import pandas as pd
!ls      # Returns the contents of the working directory.  Use "dir" in a Windows.
Run Code Online (Sandbox Code Playgroud)

返回:

Book1.xlsx
common_excel_tasks.ipynb

然后我使用以下命令:

excel_file = 'Book1.xlsx'
df1 = pd.read_excel(excel_file)
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-28585effb1ed> in <module>
      1 excel_file = 'Book1.xlsx'
----> 2 df1 = pd.read_excel(excel_file)

/usr/local/lib/python3.7/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    206                 else:
    207                     kwargs[new_arg_name] = new_arg_value
--> 208             return func(*args, **kwargs)
    209 
    210         return wrapper

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, …
Run Code Online (Sandbox Code Playgroud)

python pandas jupyter-notebook

3
推荐指数
1
解决办法
6435
查看次数

标签 统计

jupyter-notebook ×1

pandas ×1

python ×1